I’m trying to make it so that the form inputs someone submits repopulates if the submitter returns to the form. Easy for text fields, but I’m having a problem with select dropdowns.
Here’s what I have:
[code=php]
<?php
$sel2_sel1 = ‘selected=”selected”‘;
if ($_SESSION[‘frm_start_h’] != “”) {
$opt1 = “sel2_sel” . $_SESSION[‘frm_start_h’];
$$opt1 = ‘ selected=”selected’;
}
?>
<select name=”frm_start_h” id=”frm_start_h”>
<option value=”1″<?=$sel2_sel1?>>1</option>
<option value=”2″<?=$sel2_sel2?>>2</option>
<option value=”3″<?=$sel2_sel3?>>3</option>
<option value=”4″<?=$sel2_sel4?>>4</option>
<option value=”5″<?=$sel2_sel5?>>5</option>
<option value=”6″<?=$sel2_sel6?>>6</option>
<option value=”7″<?=$sel2_sel7?>>7</option>
<option value=”8″<?=$sel2_sel8?>>8</option>
<option value=”9″<?=$sel2_sel9?>>9</option>
<option value=”10″<?=$sel2_sel10?>>10</option>
<option value=”11″<?=$sel2_sel11?>>11</option>
<option value=”12″<?=$sel2_sel12?>>12</option>
</select>
But the weird thing is, if someone selects, say, “8” and submits, when they return to the form the “9” will be selected!
No matter what, the item below (in position, or above in value) the one actually selected will be the one that gets re-selected.
The scripting looks fine to me; what am I missing?
Thanks for any feedback!
Liam