Hi,
How to get the value from drop down menu into javascript function, I need the value not the selected option.
Here is the code
If the user selects an option for eg, if he selects "Cape Fear" then I will get the same thing in the javascript function, but what I need is "m1"., i.e. if he selects "The omen" I need "m3". How to do this. Please help me.
With regards
How to get the value from drop down menu into javascript function, I need the value not the selected option.
Here is the code
Code:
<html>
<head>
<script type="text/javascript">
function disp_text()
{
var w = document.myform.mylist.selectedIndex;
var selected_text = document.myform.mylist.options[w].text;
alert(selected_text);
}
</script>
<FORM NAME="myform">
<SELECT NAME="mylist" onChange="disp_text()">
<OPTION VALUE="m1">Cape Fear
<OPTION VALUE="m2">The Good, the Bad and the Ugly
<OPTION VALUE="m3">The Omen
<OPTION VALUE="m4">The Godfather
<OPTION VALUE="m5">Forrest Gump
</SELECT>
</FORM>
</head>
</html>
If the user selects an option for eg, if he selects "Cape Fear" then I will get the same thing in the javascript function, but what I need is "m1"., i.e. if he selects "The omen" I need "m3". How to do this. Please help me.
With regards
Comment