javascript value of selected option
// what is the value of the selected option?
this.options[this.selectedIndex].value
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
this.options[this.selectedIndex].value
/** * For select menus. */ function select_from_menu($menu,$choices,$deselect=true) { if ($deselect) $menu = preg_replace('/ selected(="selected")?/','',$menu); if(!is_array($choices)) { $menu = preg_replace('/(value="'.preg_quote($choices).'")/',"$1 selected=\"selected\"",$menu); } else foreach($choices as $value) { $menu = preg_replace('/(value="'.preg_quote($value).'")/',"$1 selected=\"selected\"",$menu); } return $menu; } /** * For radio buttons and checkboxes. */ function check_from_menu($menu,$choices,$deselect=true) { if ($deselect) $menu = preg_replace('/ checked(="checked")?/','',$menu); if(!is_array($choices)) { $menu = preg_replace('/(value="'.preg_quote($choices).'")/',"$1 checked=\"checked\"",$menu); } else foreach($choices as $value) { $menu = preg_replace('/(value="'.preg_quote($value).'")/',"$1 checked=\"checked\"",$menu); } return $menu; }