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

Database query w drop-down - how to keep chosen value selected?

Status
Not open for further replies.

caitlin

Technical User
Jun 21, 2002
15
US
Hi all -
I'm using the Database Wizard to create simple ASP pages that query an Access database. The query is done with a drop-down list. However, once the user chooses a value and the page updates, the drop-down is empty.

Is there a way to make the drop-down maintain the user's choice when the page refreshes? Otherwise it's not clear to them which option they chose.

Thanks!

-Caitlin
 
one way is to make one of the choices in the database a variable and have it be selected all the time

for instance, say that the choice blue was most common, in a simple colour chooser
<%
colour = request.form(&quot;D1&quot;)
if colour = &quot;&quot; then
colour = &quot;blue&quot;
%>
<form method = &quot;post&quot; action = &quot;self.asp&quot;>
<select size=&quot;1&quot; name=&quot;D1&quot;>
<option selected><% =colour %></option>
<option>black</option>
<option>blue</option>
<option>orange</option>
<option>red</option>
</select>
<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;submit&quot;>
</form>

note : change self.asp for the name of the page, the above script should keep your selected field in the option list... i hope... dont quote me on that, i am not a proffesional programmer as sorts...

Hope it helps
 
i forgot to add the end if

Place it in your script like this

if colour = &quot;&quot; then
colour = &quot;blue&quot;
end if
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top