PHP and form select
Posted: Sat Jul 17, 2010 9:59 pm
Hi, How would i got about a html form with a drop/selection box to have a default selection from users submitting. atm i got
and so on.... is there an easier more convenient way? thanks
Code: Select all
<select name="required[DOB_month]">
<option <? if ($_POST['required']['DOB_month'] == 1) { echo 'selected="selected"'; } ?>value="1">JAN</option>
<option <? if ($_POST['required']['DOB_month'] == 2) { echo 'selected="selected"'; } ?>value="2">FEB</option>
<option <? if ($_POST['required']['DOB_month'] == 3) { echo 'selected="selected"'; } ?>value="3">MAR</option>
<option <? if ($_POST['required']['DOB_month'] == 4) { echo 'selected="selected"'; } ?>value="4">APR</option>
<option <? if ($_POST['required']['DOB_month'] == 5) { echo 'selected="selected"'; } ?>value="5">MAY</option>
<option <? if ($_POST['required']['DOB_month'] == 6) { echo 'selected="selected"'; } ?>value="6">JUN</option>
<option <? if ($_POST['required']['DOB_month'] == 7) { echo 'selected="selected"'; } ?>value="7">JUL</option>
<option <? if ($_POST['required']['DOB_month'] == 8) { echo 'selected="selected"'; } ?>value="8">AUG</option>
<option <? if ($_POST['required']['DOB_month'] == 9) { echo 'selected="selected"'; } ?>value="9">SEP</option>
<option <? if ($_POST['required']['DOB_month'] == 10) { echo 'selected="selected"'; } ?>value="10">OCT</option>
<option <? if ($_POST['required']['DOB_month'] == 11) { echo 'selected="selected"'; } ?>value="11">NOV</option>
<option <? if ($_POST['required']['DOB_month'] == 12) { echo 'selected="selected"'; } ?>value="12">DEC</option>
</select>