Determining the Value or Text of the Selected Option : List « Form Control « JavaScript DHTML






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

1.Determining the Values of Multiselection Lists
2.Determining the Size of the List
3.Selection List Event Handling
4.Cycling through a Multiple-Selection List