Click to See Complete Forum and Search --> : Dropdown with query results and value


Trillian
August 20th, 2003, 06:17 PM
Is it possible to include a generic default "prompt value" in a dropdown field that's populated by a query?

It should look like:
"Select a value from the list" (First item)
Option 1 (Query value 1)
Option 2 (Query value 2)
etc.

Also, what's the trick to having the dropdown appear blank before the user clicks the arrow to see values? Now I have just the query populating the dropdown and it's not "selected" but the first item is always displayed.

I'm trying to use the onchange event to let users select a dropdown value without having to click a find or go button. If the first list value isn't blank or a prompt the first value can never be selected by clicking on it becuase it hasn't "changed".

This is a frontpage based web; the dropdown is on an asp page.

(internet based web with mdb)

ZoSoo7
August 26th, 2003, 09:17 PM
Give this a try:

<select name=myselect id=myselect>
<option selected>Select a value from the list</option>
<option>Query data</option>
<option>Query data2</option>
</select>

if you want a blank, simply put
<option>&nbps;</option>

Whenever you want to have an item selected, just do this
<option selected>Whatever</option>

You will need to use some server side code to determine if the value needs to be selected, for example
<option <%if oRs("value") = request.form("mybox" ) then response.write "selected"%>>value</option>

This will do if for you. Good luck.