Forums
This topic is locked
maintaining state
08 Nov 2006 22:58:01 john leno posted:
I have a mutli select form fields e.g.:<select name="Location" multiple="multiple" >
<option value="8">Anglesey</option>
<option value="11">Cheshire</option>
<option value="5">Conwy</option>
</select>
say i select the first 2 of the 3 options and submit my page e.g. :
mypage.asp?Location=8&Location=11
how would i then set the state of the options to selected e.g. :
<option value="8" selected="selected">Anglesey</option>
<option value="11" selected="selected">Cheshire</option>
<option value="5">Conwy</option>
help and suggestions appreciated
Replies
Replied 09 Nov 2006 04:55:35
09 Nov 2006 04:55:35 LorD ExoskeletoN replied:
hi try this, maybe it'l help.
you must have a vbscript for that example...
<option value="8" <% If location = 8 Then
Response.Write("selected"
End If %>>Anglesey</option>
<option value="11" <% If location = 11 Then
Response.Write("selected"
End If %>>Cheshire</option>
<option value="5">Conwy</option>
that's the logic...hope it'l help you...good luck
<div align=right>
Burn RUBBER Not SOUL
www.nasbikesphilippines.bravehost.com
<img src="www.motorcyclephilippines.com/forums/signaturepics/sigpic14460_2.gif" border=0></div id=right>
you must have a vbscript for that example...
<option value="8" <% If location = 8 Then
Response.Write("selected"
End If %>>Anglesey</option>
<option value="11" <% If location = 11 Then
Response.Write("selected"
End If %>>Cheshire</option>
<option value="5">Conwy</option>
that's the logic...hope it'l help you...good luck
<div align=right>
Burn RUBBER Not SOUL
www.nasbikesphilippines.bravehost.com
<img src="www.motorcyclephilippines.com/forums/signaturepics/sigpic14460_2.gif" border=0></div id=right>
Replied 09 Nov 2006 14:20:42
09 Nov 2006 14:20:42 john leno replied:
hi thanks for the response... however if collect the 'location' parameter from the URL there are 2 values
e.g.
<% =Reques.querystring("location" %>
which returns :
8,11
so the selected state would never match as theres more than 1 number.. anyone any suggestions ?
e.g.
<% =Reques.querystring("location" %>
which returns :
8,11
so the selected state would never match as theres more than 1 number.. anyone any suggestions ?
Replied 10 Nov 2006 02:54:45
10 Nov 2006 02:54:45 LorD ExoskeletoN replied:
ok so you make use of an array in this case...
<% array=Reques.querystring("location" %>
then make a "foreach statement" like this:
Code:
<%
For Each i in myarray
Rem You can place all of the code you desire inside a For Each loop
Next
%>
see this link:
www.devguru.com/Technologies/vbscript/quickref/foreach.html
hope this will help...good luck!!!
<div align=right>
Burn RUBBER Not SOUL
www.nasbikesphilippines.bravehost.com
<img src="www.motorcyclephilippines.com/forums/signaturepics/sigpic14460_2.gif" border=0></div id=right>
<% array=Reques.querystring("location" %>
then make a "foreach statement" like this:
Code:
<%
For Each i in myarray
Rem You can place all of the code you desire inside a For Each loop
Next
%>
see this link:
www.devguru.com/Technologies/vbscript/quickref/foreach.html
hope this will help...good luck!!!
<div align=right>
Burn RUBBER Not SOUL
www.nasbikesphilippines.bravehost.com
<img src="www.motorcyclephilippines.com/forums/signaturepics/sigpic14460_2.gif" border=0></div id=right>