lets say you have a form, each entry hold a month, example:
I then have a $CurrentMonth which holds the int value for the month that I want selected.Code:<option value='1'>January</option><option value='2'>February</option><option value='3'>March</option><option value='4' SELECTED>April</option><option value='5'>May</option><option value='6'>June</option><option value='7'>July</option><option value='8'>August</option><option value='9'>September</option><option value='10'>October</option><option value='11'>November</option><option value='12'>December</option>
Is there some trick to doing this effectly of do i simple do something like:
echo start of data
check if check should be there
echo end of data
then do that for each month... (ive done this before but it just seem VERY inefficiant and messy)
edit: this is what I currently have.... problem is its very bad code... and I also got 2 do this with the year (and there are many more then 12 events).... Maybe it can be done with a array or something...
Code:if (intval($vMonth) == 1) $DateInput.= " SELECTED"; $DateInput.= ">January</option><option value='2'"; if (intval($vMonth) == 2) $DateInput.= " SELECTED"; $DateInput.=">February</option><option value='3'"; if (intval($vMonth) == 3) $DateInput.= " SELECTED"; $DateInput.=">March</option><option value='4'"; if (intval($vMonth) == 4) $DateInput.= " SELECTED"; $DateInput.=">April</option><option value='5'"; if (intval($vMonth) == 5) $DateInput.= " SELECTED"; $DateInput.=">May</option><option value='6'"; if (intval($vMonth) == 6) $DateInput.= " SELECTED"; $DateInput.=">June</option><option value='7'"; if (intval($vMonth) == 7) $DateInput.= " SELECTED"; $DateInput.=">July</option><option value='8'"; if (intval($vMonth) == 8) $DateInput.= " SELECTED"; $DateInput.=">August</option><option value='9'"; if (intval($vMonth) == 9) $DateInput.= " SELECTED"; $DateInput.=">September</option><option value='10'"; if (intval($vMonth) == 10) $DateInput.= " SELECTED"; $DateInput.=">October</option><option value='11'"; if (intval($vMonth) == 11) $DateInput.= " SELECTED"; $DateInput.=">November</option><option value='12'"; if (intval($vMonth) == 12) $DateInput.= " SELECTED"; $DateInput.=">December</option>";




Reply With Quote