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

Resubmitting drop-down box value in hyperlink parameter

Status
Not open for further replies.
Jan 14, 2003
194
US
I have a drop-down box populated from an Access table that submits the search when an option is chosen (using the onchange=Form1.submit() in the FORM tag), as well as the <option selected><% = Request.Form("genre") %></option> so that the chosen option remains in the drop-down box after the selection is made and the results are shown.

Now, in my results table, I have 4 columns, with column1 being the default sort. In other pages where database results are displayed without a search form, I've been able to make dynamic sorting work by making the column head a hyperlink with the parameter ?sort=columnhead added to the end of the hyperlink.

In this table, however, since it involves another default when the page is displayed (that being drop-down=0), I can't seem to get the dynamic sort to work. The page comes up fine, and the drop-down works and pulls up results, but when I click on one of the column heads to re-sort the results, it resubmits the page and I start from scratch with a blank results section and the default selected on the drop-down box.

Is there a way to resubmit the already-chosen drop-down box selection when I choose the column head to re-sort?

Seems like it would relatively simple, but I'm a novice at ASP.

Thanks,
 
Okay, I managed to get it to work, SORT OF.

Here's the code for the hyperlink:
<a href="test.asp?SortColumn=column2&dropdown=<% = Request.Form("dropdown") %>">

Now, the page comes up great, and the drop-down box produces the proper results. When I click on column 2 to sort by that column, it works great.

Here's the catch. That first dynamic sort removes the selection visible from the drop-down box and restores it to the page default, so if I click on another link to sort by another column, it doesn't pull the drop-down choice again and returns the page to it's default with no results displayed. Can I correct this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top