[eluser]mattpointblank[/eluser]
Hi all.
My application has three <select> boxes for choosing time - hours / minutes / AM or PM.
I'm reading each of these values back out of the database and want to set the boxes to their appropriate values if they were already set.
My code looks like this:
Code:
<select name="startTimeHours">
<option value="01" <?php echo set_select('startTimeHours', '01', @$StartTimeHours == 01); ?>>01</option>
<option value="02" <?php echo set_select('startTimeHours', '02', @$StartTimeHours == 02); ?>>02</option>
// etc
</select>
This code is meant to work when adding a new record as well as editing an existing one (hence the somewhat-hacky @ sign preceding the variable). When editing it works fine, it selects the correct row. When adding a new row, however, the form comes with '09' in the Hours dropdown pre-selected. Since $StartTimeHours doesn't exist when adding a new row (trying to echo it produced an error), I don't know why the code has decided that it's equal to '09'.
Does anyone have any idea?