I have a function that creates a select list:
function make_select_ns( $name,$array,$p ersist){
$string = "<select name=\"$name\"> ";
$string .="<option selected>" . ucfirst($name) . "</option>\n";
if ($name == $array[0]){array_shift($ array);} //removes duplicate when
table name equals 1st item in array
foreach ($array AS $value) {
if (($value == $persist) && is_string($pers ist)){$selected =
"selected"; }
else {$selected = "";}
$string .= "<option $selected value='" .
str_pad($value, 2,"0",STR_PAD_L EFT) . "'>$value</option>\n";
}
$string.="</select>";
print $string;
}
I have arrays for Months, Days, Years, Hours, and Minutes.
All of the arrays work as expected except for the minutes array which
starts at 0 and goes to 55 in increments of 5. Whenever this loads
after a post the value 0 is selected. What am I missing here? Why
does the zero seem to be causing me problems?
Let me know if you need more information.
Thanks,
-Mark
function make_select_ns( $name,$array,$p ersist){
$string = "<select name=\"$name\"> ";
$string .="<option selected>" . ucfirst($name) . "</option>\n";
if ($name == $array[0]){array_shift($ array);} //removes duplicate when
table name equals 1st item in array
foreach ($array AS $value) {
if (($value == $persist) && is_string($pers ist)){$selected =
"selected"; }
else {$selected = "";}
$string .= "<option $selected value='" .
str_pad($value, 2,"0",STR_PAD_L EFT) . "'>$value</option>\n";
}
$string.="</select>";
print $string;
}
I have arrays for Months, Days, Years, Hours, and Minutes.
All of the arrays work as expected except for the minutes array which
starts at 0 and goes to 55 in increments of 5. Whenever this loads
after a post the value 0 is selected. What am I missing here? Why
does the zero seem to be causing me problems?
Let me know if you need more information.
Thanks,
-Mark
Comment