// parameters // name: the name attribute you want for the tag // // values: a hash that contains the values and labels for // the tags // // javascript: javascript for the tag, i.e. // onChange="this.form.submit()" [optional] // // size: the SIZE attribute for the tag [optional] // // if ( !defined('POPUP_MENU_DEFINED') ) { define('POPUP_MENU_DEFINED', TRUE); function popup_menu ($name, $values, $javascript = "", $size = 1) { // grab this to maintain state global $$name; $selected = ($$name) ? $$name : ""; // start building the popup meny $result = " if ($size != 1) $result .= " size=\"$size\""; if ($javascript) $result .= " " . $javascript; $result .= ">\n"; $result .= "\n"; // list all the options while ( list( $value, $label ) = each( $values ) ) { // printed SELECTED if an item was previously selected // so we maintain the state if ($selected == $value) { $result .= "$label\n"; } else { $result .= "$label\n"; } } // finish the popup menu $result .= "\n"; echo $result; } } ?>