Determining the Value or Text of the Selected Option
<html>
<head>
<script language = "JavaScript">
function getSelectValue(selectObject) {
return selectObject.options[selectObject.selectedIndex].value
}
</script>
</head>
<body>
<form name="form1">
Songs:
<select NAME="songs" SIZE=1>
<option VALUE="AA">AA</option>
<option VALUE="BB">BB</option>
<option VALUE="CC">CC</option>
<option VALUE="DD">DD</option>
<option VALUE="EE">EE</option>
<option VALUE="FF">FF</option>
</SELECT><p>
<input type=button value="Show Current" onClick="alert(getSelectValue(this.form.songs))">
</form>
</body>
</html>
Related examples in the same category