| px | top | add code | search | signup | login | help |
/* formDropDown - create an HTML <SELECT>
* vars: $name - the form variable NAME
* $value - the SELECTED option
* $labels - assoc. array, list of values=>labels
* returns: string, HTML (i.e. for use in echo or print statement)
*/
function formDropDown($name,$value,$labels) {
$html = "<SELECT NAME=\"$name\">\n";
$key = key($labels);
while($key != "") {
if ($key == $value) {
$selected = "SELECTED";
} else {
$selected = "";
}
$html .= "<OPTION VALUE=\"$key\" $selected>$labels[$key]\n";
next($labels);
$key = key($labels);
}
$html .= "</SELECT>\n";
return $html;
}
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.