Javascript gets the current value of the select sample code of IE and Firefox and Opera and Chrome compatibility
**JavaScript gets the current value of Select **Var value = document. GetElementById (” select ”). The options [document. GetElementById (” select ”). The options. SelectedIndex]. Value; Var text = document. GetElementById (” select ”). The options [document. GetElementById (” select ”). The options. SelectedIndex]. The text;
**Example: **
<script>
function check() {
var select = document.getElementById("select").options[document.getElementById("select").options.selectedIndex].value;
alert(select);
}
</script>
<select name="select" id="select">
<option value="test1" selected="selected">Test1</option>
<option value="test2">Test2</option>
</select>
<input type="button" value=" I want to try " onclick="check()"/>