SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: ASP _ Listbox

  1. #1
    SitePoint Enthusiast hombre_de_las_ca's Avatar
    Join Date
    Apr 2005
    Location
    Bangalore, India
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question ASP _ Listbox

    Is it possible to change the selected default option in a listbox on the 2nd page to the option selected in a listbox on the 1st page which ..i.e preventing the selected option from changing to the default option on the 2nd page (both the list boxes have the same value)...i am having a listbox which gets populated from a database using ASP.

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes but its a pain, if your using a dynamic listbox, all you need to do is add,

    <select>
    <% do while not rs.eof %>
    <option value="<%= rs("selectvalue") %>"<% if request.form("select") = rs("selectvalue") then response.write " selected" end if %>><%= rs("selecttext") %><% rs.movenext
    loop %>
    <option>
    </select>

    Haven't tested it but when value equals one of the opions in the select box, it will select it.

    Gav

  3. #3
    SitePoint Enthusiast Nawaz Ijaz's Avatar
    Join Date
    Feb 2005
    Location
    Lahore, Pakistan
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just check the code, its works..

    <select name=yourListbox size="1">
    <%
    Do Until rs_country.EOF
    %>

    <option value="<%= rs_country("Nationality")%>" <% if( yourListbox= rs_country("Nationality")) then %> selected <% end if%> > <%= rs_country("Nationality")%></option>
    <%
    rs_country.MoveNext
    Loop
    rs_country.close
    %>
    </select>
    Nawaz Ijaz [Lahore, Pakistan]
    Boy: He is big..i wont like to fight him...
    Achilles: Thatz Y no one wud remember u after thousand years...!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •