Why this Simple Javascript function not working in Internet Explorer Version 8.
Why myvalue is empty in Internet Explorer.
javascript debug myvalue==
This is working fine in Chrome/Firefox and shows the selected value correctly.
javascript debug myvalue=Item2=
Code
<html>
<script type="text/javascript">
function showValue(myvalue)
{
document.write("javascript debug myvalue=" + myvalue + "=\n");
}
</script>
<body>
<select id="items" onchange="showValue(this.value);">
<option>Item1</option>
<option>Item2</option>
<option>Item3</option>
</select>
</body>
</html>
That’s because you don’t have VALUES in your options. Something like this will work:
But, if you actually need option’s TEXT and not VALUE, you should use this:
Refer to HTMLOptionElement DOM spec for more info on options.