Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Please Help with my code (keeping and passing listbox values)


Message #1 by George Lavrov <glavrov@m...> on Mon, 11 Mar 2002 11:11:08 -0800
Hi fellows,



Please help me to figure out what is wrong with my script...

My goal is to keep selected multiple choices from listbox in case if user is

transferred back (redirected) from the next page. I know how to accomplish

it for dropdown menu, but with listbox I am kind of stuck. I am trying to

use code below, but then my dynamically generated list values are

disappearing on initial page load. If I to move first

IF..Then..For..Next..Endif at the bottom of the page and use response.write,

I'll get my values displayed. So I know it is right way to go except my

logic with If ..Then is broken :(



Thanks in advance.

George



<select name="Regions" size="5" multiple>



<%

While (NOT rsRegions.EOF)

If Request.Form("Regions").count > 1 Then

For x=1 to Request.Form("Regions").count

If CINT(rsRegions.Fields("RegionID")) = Request.Form("Regions")(x) Then

%>



<option selected value="<%=(rsRegions.Fields.Item("RegionID").Value)%>"

><%=(rsRegions.Fields.Item("Description").Value)%></option>



<% ELSE %>



<option value="<%=(rsRegions.Fields.Item("RegionID").Value)%>"

><%=(rsRegions.Fields.Item("Description").Value)%></option>



<% End IF %>

<% Next %>

<% End IF %>



<%

rsRegions.MoveNext()

Wend

If (rsRegions.CursorType > 0) Then

rsRegions.MoveFirst

Else

rsRegions.Requery

End If

%>

</select>






  Return to Index