View Single Post
  #1  
Old 01-08-2009, 11:56 AM
 
AMMoyer AMMoyer is offline
 

Senior Member
  
Join Date: Nov 2008
Posts: 150
 

Default Retaining selected Item in dropdown menu

I have a template I've written that is visible above the categories in the left menu. The template has a series of dropdown boxes. When a year is selected from the first the onchange event fires a query to fill the second combo box and the page reloads. What happens is that the value of the year is not remaining in the first box. The second box is populated, but the first box still says "Select Year". I just tried adding the {if} statement to the first dropdown, but no luck. I have also tried adding a series of selection lines that look like:

<option value="2009" {php} if (!(strcmp(2009, $year))){echo "selected";}{/php}>2009</option>

Without any success. How do I get the selected year to stick when the page reloads?

Here is the tpl code:
Code:
{capture name=menu} <form method="post" action="mmy.php" name="mmysearchform"> <select name="year" style="width: 90%;"onchange="javascript:document.mmysearchform.submit ();"> {if $year == ''} <option value="" selected="selected">Select Year</option> {elseif $year > 1950} <option value=$year selected="selected">"$year"</option> {/if} <option value="2009">2009</option> <option value="2008">2008</option> <option value="2007">2007</option> <option value="2006">2006</option> <option value="2005">2005</option> <option value="2004">2004</option> <option value="2003">2003</option> <option value="2002">2002</option> <option value="2001">2001</option> <option value="2000">2000</option> <option value="1999">1999</option> </select><br> {* {html_options name=year options=$yearid style="width: 90%;" onchange="javascript:document.mmysearchform.submit ();"}<br> *} {if $year == ''} <select name="make" style="width: 90%;" disabled="disabled"> <option value="" selected="selected">Select Make</option> {elseif $year > 1950} {html_options name=make values=$makeid output=$makename style="width: 90%;" onchange="javascript:document.mmysearchform.submit ();"}<br> {/if} {if $make == ''} <select name="model" style="width: 90%;" disabled="disabled"> <option value="" selected="selected">Select Model</option> {/if} {html_options name=model values=$modelid output=$modelname style="width: 90%;"}<br> <div id="mmy" align="center"> <input name="getparts" type="submit" value="Get Parts" /> </div> </form>
__________________
Adam
X-Cart Gold 4.4.5 - Live
X-Cart Gold 4.1.11 - Retired
X-Payments 1.0.4
CDSEO Pro
EWD Hosting

Last edited by AMMoyer : 01-08-2009 at 11:56 AM. Reason: adding code tags
Reply With Quote