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 bkrike 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 FrontPage 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 (hopefully simple) 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.

The simpler the better since I don't know much ASP and frontpage will likely mess it up anyway...

Thanks!

-Caitlin
 
Hi Caitlin,

I always use something like this...
Code:
...rest of form code...
<SELECT NAME=somename>
<OPTION>Please select one...</OPTION>
<OPTION></OPTION>
<%
While NOT objRecordset.EOF
  If Request.Form(&quot;somename&quot;) = objRecordset(&quot;Value1&quot;) Then
    strSelected = &quot; SELECTED&quot;
  Else
    strSelected = &quot;&quot;
  End If

  Response.Write &quot;<OPTION VALUE='&quot; & objRecordset(&quot;Value1&quot;) & &quot;'&quot; & strSelected & &quot;>&quot; & objRecordset(&quot;Value2&quot;) & &quot;</OPTION>&quot; & vbcrlf

  objRecordset.MoveNext
Wend
</SELECT>
...rest of form code...
%>
Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top