Forums

ASP

This topic is locked

Using the If , Then, Else statements?

Posted 12 Jul 2001 14:26:37
1
has voted
12 Jul 2001 14:26:37 Davy Fennell posted:
I have listed the contents of a repeat region table I have created below. Presently, When the user clicks on the client name it loads
up a web form called "updateCAFOECTCI.asp". This works fine based on one web form. However, I now need to change how it works
so that the user can link to a particular web form pertaining to the client. There are 5 different web forms each determind
by the "FormCategory" ("updateCAFOECTCI.asp","updateCAFEVCTCI.asp","updateCAFOEGUI.asp", "updateCAFEVGUI.asp","RAF.asp".
I know this can be done by adding some asp code to my html below. Can someone possibly show me the code to be able to do this. Unfortunately
my asp skills are virtually non-existant. Perhaps there is an extension someone knows off.

Any help much appreciated.

Davy



<tr>
<td class="normal"><%=(RsCAFs.Fields.Item("FormCategory".Value)%></td>
<td class="normal"><A HREF="updateCAFOECTCI.asp?<%= MM_keepURL & MM_joinChar(MM_keepURL) & "ID=" & RsCAFs.Fields.Item("ID".Value %>"><%=(RsCAFs.Fields.Item("CustomerName".Value)%></A></td>
<td class="normal"><%=(RsCAFs.Fields.Item("BusinessUnit".Value)%></td>
<td class="normal"><%=(RsCAFs.Fields.Item("DateReceived".Value)%></td>
<td class="normal"><%=(RsCAFs.Fields.Item("DateConfigured".Value)%></td>
<td class="normal"><%=(RsCAFs.Fields.Item("DateCheck".Value)%></td>
<td class="normal"><%=(RsCAFs.Fields.Item("DateActive".Value)%></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
RsCAFs.MoveNext()
Wend
%>
</table>
<p> </p>
</body>
</html>
<%
RsCAFs.Close()
%>

Replies

Replied 12 Jul 2001 15:18:54
12 Jul 2001 15:18:54 Joel Martinez replied:
hmm... I think that I understand what you are trying to say.... depending on what value the Formcategory has, you want them to redirect to somwhere else... I think this may do it:

<tr>
<td class="normal">
<b>&lt;%
SELECT CASE (RsCAFs.Fields.Item("FormCategory".Value)
CASE 0
response.write("&lt;a href=""updateCAFOECTCI.asp?ID=" & RsCAFs.Fields.Item("ID".Value &"""&gt;"& RsCAFs("FormCategory" &"&lt;/a&gt;"

CASE 1
response.write("&lt;a href=""updateCAFEVCTCI.asp?ID=" & RsCAFs.Fields.Item("ID".Value &"""&gt;"& RsCAFs("FormCategory" &"&lt;/a&gt;"

END SELECT
%&gt;</b>&lt;/td&gt;
&lt;td class="normal"&gt;&lt;A HREF="updateCAFOECTCI.asp?&lt;%= MM_keepURL & MM_joinChar(MM_keepURL) & "ID=" & RsCAFs.Fields.Item("ID".Value %&gt;"&gt;&lt;%=(RsCAFs.Fields.Item("CustomerName".Value)%&gt;&lt;/A&gt;&lt;/td&gt;

----------

you can add as many case statements as you need... keep in mind that I don't know what querystring values these pages need, so I assumed that all they needed was the ID from the recordset...

hope it helps,
Joel Martinez

----------
Is this thing on?....
Replied 12 Jul 2001 15:36:43
12 Jul 2001 15:36:43 Waldo Smeets replied:
Ever tried the conditional region extension? www.UDzone.com/go?628

Waldo Smeets - www.UDzone.com Webmaster
------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
------------------------------------------
Replied 13 Jul 2001 13:16:42
13 Jul 2001 13:16:42 Davy Fennell replied:
Hi Joel,

Thanks very much for the help. I have tried your code and keep getting the following error:

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: "EVGUI"]'
/CS/TMP1so0kgfeqx.asp, line 120

Can this be done using the If statements, e.g. If the FormCategory value is EVGUI then load updateCAFEVGUI.asp or If FormCategory value value is OEGUI then load updateCAFOEGUI.asp etc etc

Many thanks

Davy


<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
hmm... I think that I understand what you are trying to say.... depending on what value the Formcategory has, you want them to redirect to somwhere else... I think this may do it:

&lt;tr&gt;
&lt;td class="normal"&gt;
<b>&lt;%
SELECT CASE (RsCAFs.Fields.Item("FormCategory".Value)
CASE 0
response.write("&lt;a href=""updateCAFOECTCI.asp?ID=" & RsCAFs.Fields.Item("ID".Value &"""&gt;"& RsCAFs("FormCategory" &"&lt;/a&gt;"

CASE 1
response.write("&lt;a href=""updateCAFEVCTCI.asp?ID=" & RsCAFs.Fields.Item("ID".Value &"""&gt;"& RsCAFs("FormCategory" &"&lt;/a&gt;"

END SELECT
%&gt;</b>&lt;/td&gt;
&lt;td class="normal"&gt;&lt;A HREF="updateCAFOECTCI.asp?&lt;%= MM_keepURL & MM_joinChar(MM_keepURL) & "ID=" & RsCAFs.Fields.Item("ID".Value %&gt;"&gt;&lt;%=(RsCAFs.Fields.Item("CustomerName".Value)%&gt;&lt;/A&gt;&lt;/td&gt;

----------

you can add as many case statements as you need... keep in mind that I don't know what querystring values these pages need, so I assumed that all they needed was the ID from the recordset...

hope it helps,
Joel Martinez

----------
Is this thing on?....
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Replied 13 Jul 2001 13:24:27
13 Jul 2001 13:24:27 Davy Fennell replied:
Waldo,

I looked at the Conditional Region tutorial and don't think it meets my needs. I need to display a user form that does not leave gaps where there is no data. Does the Cond Reg extension allow me to pick and choose fields and display them on a complete table without blanks showing. Do you know what I mean?

Davy


<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Ever tried the conditional region extension? www.UDzone.com/go?628

Waldo Smeets - www.UDzone.com Webmaster
------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
------------------------------------------
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Replied 13 Jul 2001 14:28:44
13 Jul 2001 14:28:44 Joel Martinez replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: "EVGUI"]'
/CS/TMP1so0kgfeqx.asp, line 120
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

well, if you used the script exactly as I provided, then yes, you would get that error because the values that my script is checking for, are numbers. it would work if you changed the numbers to the text possibilities of the rs Field.

<b>
&lt;%
SELECT CASE (RsCAFs.Fields.Item("FormCategory".Value)
CASE "OECTCI"
response.write("&lt;a href=""updateCAFOECTCI.asp?ID=" & RsCAFs.Fields.Item("ID".Value &"""&gt;"& RsCAFs("FormCategory" &"&lt;/a&gt;"

CASE "EVECTCI"
response.write("&lt;a href=""updateCAFEVCTCI.asp?ID=" & RsCAFs.Fields.Item("ID".Value &"""&gt;"& RsCAFs("FormCategory" &"&lt;/a&gt;"

END SELECT
%&gt;
</b>

but, now that I know a bit more about the data your working with, another (smaller) solution might work... if the URL is just the db field wrapped by updateCAF[dbField].asp, then you might try this...

<pre id=code><font face=courier size=2 id=code>
&lt;%=("&lt;a href=""updateCAF"& RsCAFs("FormCategory" &".asp?ID=" & RsCAFs.Fields.Item("ID".Value &"""&gt;"& RsCAFs("FormCategory" &"&lt;/a&gt;"%&gt;
</font id=code></pre id=code>

in place of the whole script I gave before

hope that works,
Joel Martinez

----------
Is this thing on?....

Edited by - joelmartinez on 07/13/2001 14:30:06

Edited by - joelmartinez on 07/13/2001 14:30:37

Edited by - joelmartinez on 07/13/2001 14:32:14
Replied 16 Jul 2001 14:34:11
16 Jul 2001 14:34:11 Davy Fennell replied:

Hi Joel,

I have used the CASE statements as listed below. They work fine, each linking to its appropriate form. However, each form loads up the same database record which is the first entry in the database. I have tried jiggin around with the recordset to help make it load up the appropriate data. I can't seem to get it to work. Is there something in the code I should add.

Many thanks.

Davy


<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: "EVGUI"]'
/CS/TMP1so0kgfeqx.asp, line 120
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

well, if you used the script exactly as I provided, then yes, you would get that error because the values that my script is checking for, are numbers. it would work if you changed the numbers to the text possibilities of the rs Field.

<b>
&lt;%
SELECT CASE (RsCAFs.Fields.Item("FormCategory".Value)
CASE "OECTCI"
response.write("&lt;a href=""updateCAFOECTCI.asp?ID=" & RsCAFs.Fields.Item("ID".Value &"""&gt;"& RsCAFs("FormCategory" &"&lt;/a&gt;"

CASE "EVECTCI"
response.write("&lt;a href=""updateCAFEVCTCI.asp?ID=" & RsCAFs.Fields.Item("ID".Value &"""&gt;"& RsCAFs("FormCategory" &"&lt;/a&gt;"

END SELECT
%&gt;
</b>

but, now that I know a bit more about the data your working with, another (smaller) solution might work... if the URL is just the db field wrapped by updateCAF[dbField].asp, then you might try this...

<pre id=code><font face=courier size=2 id=code>
&lt;%=("&lt;a href=""updateCAF"& RsCAFs("FormCategory" &".asp?ID=" & RsCAFs.Fields.Item("ID".Value &"""&gt;"& RsCAFs("FormCategory" &"&lt;/a&gt;"%&gt;
</font id=code></pre id=code>

in place of the whole script I gave before

hope that works,
Joel Martinez

----------
Is this thing on?....

Edited by - joelmartinez on 07/13/2001 14:30:06

Edited by - joelmartinez on 07/13/2001 14:30:37

Edited by - joelmartinez on 07/13/2001 14:32:14
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Replied 16 Jul 2001 15:26:01
16 Jul 2001 15:26:01 Joel Martinez replied:
hmmm, it seems we have a failure to communicate...
why don't we do this,
email me the source to that page, and I'll see what if I can't spot the problem.

Joel Martinez

----------
Is this thing on?....
Replied 16 Jul 2001 17:33:30
16 Jul 2001 17:33:30 Joel Martinez replied:
ahhhh... I just re-read the previous post, and I think I just understood it... the problem no longer lies with in the case statements, but in the forms that they link to, you say that they're just pulling the first record of the recordset.

then my friend, you just need to make sure that the recordset that pulls information in those forms is looking for request.querystring("ID" as the criteria to pull records:
just make the parameter in the recordset has <pre id=code><font face=courier size=2 id=code>request.querystring("ID"</font id=code></pre id=code> as the runtime value

tell me if this is the problem,

Joel Martinez

----------
Is this thing on?....
Replied 16 Jul 2001 18:31:47
16 Jul 2001 18:31:47 Davy Fennell replied:
Joel,

It all works beautifully! Pour yourself a large beer and give yourself a pat on the back. Well deserved.

Thanks again.

Davy

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
ahhhh... I just re-read the previous post, and I think I just understood it... the problem no longer lies with in the case statements, but in the forms that they link to, you say that they're just pulling the first record of the recordset.

then my friend, you just need to make sure that the recordset that pulls information in those forms is looking for request.querystring("ID" as the criteria to pull records:
just make the parameter in the recordset has <pre id=code><font face=courier size=2 id=code>request.querystring("ID"</font id=code></pre id=code> as the runtime value

tell me if this is the problem,

Joel Martinez

----------
Is this thing on?....
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Replied 16 Jul 2001 19:01:20
16 Jul 2001 19:01:20 Joel Martinez replied:
Great <img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>

I was starting to doubt my self there for a minute

Joel Martinez

----------
Is this thing on?....

Reply to this topic