We have two select boxes in a form, one lists months and one lists years. We want use a conditional statement to test to see if each month / year option in each select box is the current month or year and then apply a selected="selected" attribute if it is. This will enable the select boxes to always default to current month / year.
I'm not quite sure where to even start in terms of php. We're looking to test if option value is equal to current month, if so, apply selected="selected", otherwise do nothing....
One section of select box:
<option label="Jan" value="1" selected="selected">Jan</option>
Here is a yearly example:
<option label="2010" value="2010" selected="selected">2010</option>
One select box currently looks like this:
<select name="sm"> <option label="Jan" value="1">Jan</option> <option label="Feb" value="2" [color=red]selected="selected"[/color]>Feb</option> <option label="Mar" value="3">Mar</option> <option label="Apr" value="4">Apr</option> <option label="May" value="5">May</option> <option label="Jun" value="6">Jun</option> <option label="Jul" value="7">Jul</option> <option label="Aug" value="8">Aug</option> <option label="Sep" value="9">Sep</option> <option label="Oct" value="10">Oct</option> <option label="Nov" value="11">Nov</option> <option label="Dec" value="12">Dec</option> </select>
Any feedback greatly appreciated!