IE select onchange issue

This is a quick tip on how to support the onChange behavior for a select box in IE8.

For some reason IE 8 does not handle the onChange attribute of a select box.


<select name="bowsers" id="browsers" onChange="alert('test');">

<option>FF4</option>

<option>IE</option>

<option>Chrome</option>

</select>

Here is a fix than can be used to make this working


<select name="bowsers" id="browsers">

<option>FF4</option>

<option>IE8</option>

<option>Chrome</option>

</select>

<script type="text/javascript">
var selectmenu = document.getElementById("browsers");

selectmenu.onchange = function()
{
 alert('test');
}

</script>

2 Responses

02.02.12

this does not work!

04.01.14

Just what I needed. Thanks man!

Leave Your Response

* Name, Email, Comment are Required