Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 Using an Onchange Event handler to trigger search

Author  Topic 

simflex
Constraint Violating Yak Guru

327 Posts

Posted - 2007-04-13 : 11:11:15
Hello (again) experts,

I have 3 dynamic dropdown listboxes that get automatically populated by querying the database.

Users then select an option from the dynamically populated dropdown listbox to perform a search.

For instance,

<select name="test">
<option value="">All tests</option>
<option>test1</option>
<option>test2</option>
<option>test3</option>
</select>

As it stands now, the user has to select one of the options, say test1 for instance, and then click Search.

Then the result is displayed in results page.

What I would like to do is put an onChange event handler into this dropdown so that anytime a user selects an option, say test1 for instance, s/he is automatically taken to the results page where the result is displayed, without the need to click on the Search button.

I tried this:

<select name="test" onchange="this.form.submit();">

However, when I select an option, it displays the first row of records from the db but won't select any other option.


Here is one of the dropdown code:

prefix = "<option>"
suffix = "</option>" & vbNewLine

Set RS = Conn.Execute("SELECT DISTINCT Test FROM testTable ORDER BY test")
temp = RS.GetString( , , , suffix & prefix )
OptionsTests = prefix & Left( temp, Len(temp)-Len(prefix) )

Then the dropdown:
<select name="test" onchange="this.form.submit();">
<option value="">All tests</option>
<%=OptionsTests%>
</select><br>

There is got to be something that refreshes the dropdown and ready it for next option selection.


Thanks very in advance for your assistance
   

- Advertisement -