#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    Newport News
    Posts
    5
    Rep Power
    0

    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
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Location
    NJ
    Posts
    428
    Rep Power
    16
    I would use a session rather than a cookie.
    When you are populating your lists via your recordset do something like this.

    Code:
    do until rs.eof 
       if rs("ZipField") = session("CurrentZip") then 
         response.write "<option value=""" & rs("ZipField") & """ selected>" & rs("ZipField") & "</option>" 
       else 
         response.write "<option value=""" & rs("ZipField") & """>" & rs("ZipField") & "</option>"
       end if 
       rs.movenext
    loop
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    Newport News
    Posts
    5
    Rep Power
    0
    Thats exactly what I was looking for. Thank you for the help. Perhaps one day I can return the favour

IMN logo majestic logo threadwatch logo seochat tools logo