| | |
retain selected value in a dropdown list
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Hello,
I have a dropdown list (single row only) of languages. If I select 'English", the page will reload, it will pass a variable of the Language ID, and all records in English will display in the table.
How can I retain the value selected in the dropdown? I want the selected language to be selected (displayed) in the dropdown list, not the first nor last.
Thanks in advance!
I have a dropdown list (single row only) of languages. If I select 'English", the page will reload, it will pass a variable of the Language ID, and all records in English will display in the table.
How can I retain the value selected in the dropdown? I want the selected language to be selected (displayed) in the dropdown list, not the first nor last.
Thanks in advance!
ASP Syntax (Toggle Plain Text)
<select name="LanguageID" onchange="myForm.submit();"> <%do while not rs.eof%> <option value="<%=rs("LanguageID")%>"><%=rs("Language")%></option> <%rs.movenext loop%> </select>
•
•
Join Date: Sep 2007
Posts: 1,080
Reputation:
Solved Threads: 68
well you can always do it via querystring or session's. just set the querystring or session to the language ID. then do this:
or session object:
ASP Syntax (Toggle Plain Text)
<select name="LanguageID" onchange="myForm.submit();"> <%do while not rs.eof%> <option value="<%=rs("LanguageID")%>" <% if Trim(Request.QueryString("languageid")) = rs("LanguageID") then %>selected<% end if %>><%=rs("Language")%></option> <%rs.movenext loop%> </select>
ASP Syntax (Toggle Plain Text)
<select name="LanguageID" onchange="myForm.submit();"> <%do while not rs.eof%> <option value="<%=rs("LanguageID")%>" <% if Session("languageid") = rs("LanguageID") then %>selected<% end if %>><%=rs("Language")%></option> <%rs.movenext loop%> </select>
Last edited by SheSaidImaPregy; Jan 21st, 2008 at 10:17 am.
![]() |
Other Threads in the ASP Forum
- Previous Thread: How can i add textboxes dynamically in an asp page
- Next Thread: Image Uploading
| Thread Tools | Search this Thread |
Tag cloud for ASP
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection calendar changeable connection current database databaseconnection diagnostics dreamweaver excel fso html iis microsoft msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption server single specfic sqlserver sqlserverconnection toolkit web webserver windows7






