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

drop down box persistance in a form

Status
Not open for further replies.

price79

IS-IT--Management
Sep 24, 2004
9
US
I am trying to make a selection box keep the selected value after the page is reloaded. I can't find how to do this easily anywhere online.

This is a form for people to select which year of car they want to search on. There is a keyword and then an onsubmit function which attaches a 2 letter year to the keyword and submits it to the search page. The user has to select the keyaord from a dropdown selection box.

After the search is performed, the person is taken to the results, but the selection box resets. When people search again and again, they have to keep opening the dropdown and selecting their year. any ideas how to keep the selection after the search is done?

Here is the HTML

-----------------------------------------------------------

<form id="find_spec" name="find_spec" method="post" action="<*SearchResultspageURL*>" onsubmit="appendgeneration();">

<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input type="hidden" id="searchtype" name="searchtype" value="AND"><input name="find_spec" type="text" class="searchbox1" id="keyword" onFocus="this.value=''" value=" Part# or Keyword(s)" maxlength="50">
</td>
<td nowrap>
<img src="<*ImageURL*>filltop.gif" width="2" height="1">
<select class="searchbox" id="generation">
<option value="Corvette" selected>Year</option>
<option value="Corvette">ALL</option>
<option value="07">2007</option>
<option value="06">2006</option>
<option value="05">2005</option>
<option value="04">2004</option>
<option value="03">2003</option>
<option value="02">2002</option>
<option value="01">2001</option>
<option value="00">2000</option>
<option value="99">1999</option>
<option value="98">1998</option>
<option value="97">1997</option> </select></td>
<td align="center" valign="middle" nowrap><input name="btnSearch" type="image" id="btnSearch2" value="Search" src="<*ImageURL*>go3.gif" width="40" height="20"></td>
</tr>
</table>
</form></div>
----------------------------------------------------------
 
This is not a question for the html forum -- you do it by simply outputting [tt]selected="selected"[/tt] at the option that was chosen. How to assign the value to the correct option would be the question for the whatever server side scripting you're using.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top