PDA

View Full Version : Simple loop


dawilis
04-09-2005, 01:48 AM
Hi all I need a loop the changes the same page from mode 1 to mode 2
Currently I have 2 hyper links Mode1 and Mode2
they just select a condition respectively used in a SQL statment
how can I loop it so if the page is already mode1 (default) then it changes to mode2 or if its mode2 then its mode 1, using only 1 button (Mode) to change
this is the current code

if DispMode = "" then
DispMode = 1
end if

if DispMode = 1 then
ResAction = "No"
else
ResAction = "Yes"
end if

miranda
04-12-2005, 05:56 PM
are you trying to do a postback by clicking a link and have the page show different content depending on which link was clicked?

dawilis
04-12-2005, 11:36 PM
If the link is clicked it will display data that sorts "Yes" in the Sql and if clicked again it sorts "no" in the Sql. Then click again and "Yes" or whatever
does that make sense?

miranda
04-13-2005, 08:44 PM
the simplest way is to Change the links to pass the parameter's yes in the yes link and no in the no link. Retrieve this value into a variable. Next change the sql statement so that it shows this variable in the sql statement.

dawilis
04-14-2005, 03:43 PM
Hi thanks for your help,
I only want 1 button so the same result will be sent each time, what I want to do is change that result whatever it is, the default is 'On" so it will display 'Off" the first time, and when clicked it will dispay "On' click it again it will display 'Off'
does that make any sense?

miranda
04-14-2005, 08:17 PM
if this form postbacks onto itself and you are going to use a button then assign a name to it and set up a hidden form field and a counter. Now when the user clicks the button then change the counter and display that result into the hidden form field like so.

<%
'determine if the counter has a value set in it or not
DispMode = Request.Form("counter")
If Request.Form("submit") = "button" Then 'the user clicked the submit button
If Len(Request.Form("counter")) = 0 Then 'the first time page is loaded there is no value
DispMode = 1
ElseIf DispMode = 0 Then
DispMode = 1
Else
DispMode = 0
End If
End If
If DispMode = 1 then
ResAction = "No"
Else
ResAction = "Yes"
End if
%>
<input type="hidden" name="counter" value="<%=DispMode%>" />
<input type="submit" name="button" value="submit" />

dawilis
04-15-2005, 12:56 AM
thanks miranda, I appreciate your efforts, Ill give that a go.

dawilis
04-15-2005, 01:27 AM
thanks miranda, I see by your code that my problem was that, I was not putting the DispMode in the actual Hyperlink to click.

miranda
04-15-2005, 04:40 AM
yes, if there is hyperlinks, then all you need to do is add the value to the string and then parse the string using the request object to get the value.