January 7th, 2004, 12:42 AM
Remember List Box selection
I have a list box that allows users to search an SQL database on ZIP, Name and so on
After the submit the List Box selection always goes back to the defaut selection.
I figured by writing the current selected item to a cookie prior to the submit I could recall it upon reload.
Does anybody know how to set default selected item for a list box? Am I going about this the right way? The more I research it seems dynamically creating the list box is the way t go
January 7th, 2004, 05:24 PM
I would use a session rather than a cookie.
When you are populating your lists via your recordset do something like this.
do until rs.eof
if rs("ZipField") = session("CurrentZip") then
response.write "<option value=""" & rs("ZipField") & """ selected>" & rs("ZipField") & "</option>"
response.write "<option value=""" & rs("ZipField") & """>" & rs("ZipField") & "</option>"
January 7th, 2004, 11:35 PM
Thats exactly what I was looking for. Thank you for the help. Perhaps one day I can return the favour