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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

list box after submit

Status
Not open for further replies.

skibascott

IS-IT--Management
Mar 18, 2004
82
US
Is it possible to preserve the selected item in a list box after a form submission. When the form is submitted the page refreshes and the list box selection is reset. How can I keep the same option selected after refresh?
 
Presuming you're building your list from a DB and that that field is being submitted in the form... if the page is submitting to itself, then you can check the request.form("formvarname"), or if it's submitting to another page and then redirecting, set the selected item as a querystring variable and request.querystring("formvarname").

Then, when you get to the select box, you'd set it up like this...

Code:
<select>
<%strSelectedOption = Request.Form("yourvarname")
While not rsBoxList.EOF%>
 <option <%if rsBoxList("option") = strSelectedOption Then response.write "selected"%>>
 <%rsBoxList.movenext
Wend

That should set you up.
 
oops, forgot to close the select box... should be...

Code:
<select>
<%strSelectedOption = Request.Form("yourvarname")
While not rsBoxList.EOF%>
 <option <%if rsBoxList("option") = strSelectedOption Then response.write "selected"%>>
 <%rsBoxList.movenext
Wend%>
</select>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top