Forum Moderators: mack
Also, if I chose to keep these drop down lists in 3 separate files and include them in the form, will there be any problem in passing the variables using the post method ?
Thanks !
...and include them in the form, will there be any problem in passing the variables using the post method
... that you have some access to server-side programming. I'll guess at PHP. Short answer, sure you can do that, but then your lists are hard-coded. There's a better way; this is not "working code" but gives you the idea:
$year_start = '1900';
$year_end = '2009';
$ddName = 'birth'; // or convert from input variables
// What you REALLY should do is get the current year
// dynamically and use that for year end.
$moName = $ddName . '_month';
$daName = $ddName . '_day';
$yrName = $ddName . '_year';
// Do some stuff here to set the values for $mm, $dd,
// $yyyy so you can set "selected" if it's present
$dtString = "
<select name=\"$moName\" id=\"$moName\">
<option value=\"\">--</option>
";
for ($i=1;$i<=12;$i++) {
$moTxt = (strlen($i)<2)?'0' . $i:$i;
$dtString .= "<option value=\"$moTxt\"";
if ($mm == $moTxt) { $dtString .= ' selected'; }
$dtString .= ">$moTxt</option>\n";
}
$dtString .= "
</select>
";
//(rinse and repeat for DAY, using 1-31)
$dtString .= "
<select name=\"$yrName\" id=\"$yrName\">
<option value=\"\">--</option>
";
for ($i=$start_year;$i<=$end_year;$i++) {
$dtString .= "<option value=\"$i\"";
if ($yyyy == $i) { $dtString .= ' selected'; }
$dtString .= ">$i</option>\n";
}
$dtString .= "
</select>\n";
Now output $dtString and you have your date selects . . . . apply the same concepts for a time list.