Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selected index in list box

Status
Not open for further replies.

mihalych

Programmer
Jul 24, 2003
27
US
When I populate list box with server-side scripts like:

<select size=&quot;1&quot; name=&quot;selSport&quot;>
<% Do While Not rsCategory.EOF%>
<option <%Response.Write(strSelected)%>
value=<% =rsCategory(&quot;CategoryID&quot;) %>><% =rsCategory (&quot;CategoryName&quot;)%>
<% rsCategory.MoveNext %>
<% Loop %>
</select>

Then I would like to select item in the list box and resubmit the form to itself. The list box displays first item but how can it display the item that was selected before the form was submitted?
 
<%

fieldVal = request(&quot;selSport&quot;)

set rs = cn.execute(&quot;select fieldName From myTable&quot;)

optStr = &quot;<option value=''>Choose One&quot;
do while not rs.eof
if rs(0) = fieldVal then key = &quot;selected&quot; else key = &quot;&quot;
optStr = optStr & &quot;<option value='&quot; & rs(0) & &quot;' &quot; & key & &quot;>&quot; & rs(0)
rs.movenext
loop

%>

<select size=&quot;1&quot; name=&quot;selSport&quot;><%=optStr%></select>


Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top