Get the value of the select box in ie
Posted by navaneeth on May 25, 2013 in General, HTML, Javascript | No comments yet
We can’t access the option value using javascript on Internet Explorer using the normal javascript method.ie we cant get the value of the select box in ie
IE is looking for the value attribute. It looks like other browsers are defaulting to the text displayed as the value if value=”” is not found on the option tag. The following is what works on all major browsers.
<form name="myform"> <select id='select' name="select"> <option value='one'>one</option> </select> </form>
<script> var index = document.myform.select.selectedIndex; var value = document.myform.select.options[index].value; alert(value); // Alerts 'one' </script>
By this code we can get the value of selectbox
Leave a Reply