Normally when we select a value from drop bax then we get the value of option. Here when we will select a value of option then we will getting text of option.
SO to get selected drop box text use below code example-
Javascript
function get(text){
var value = text.options[text.selectedIndex].text;
alert(value);
}
HTML:
Use get(this) in your html select tag.
onchange="get(this);"
DEMO:
<script type="text/javascript">
function get(text){
var value = text.options[text.selectedIndex].text;
if(value != '')
{
alert(value);
}
}
</script>
0 Comment(s)