I have a select tag in my HTML and in Internet Explorer, when it is called from a JavaScript function an error occurs.
This is the html creates the select box-
<select id="item1" name="Item 1" onchange ="fn();">
<option value="0">Please select gender</option>
<option value="1">Male</option>
<option value="2">Female</option>
</select>
function for onchange event of select-
function fn()
{
var s = document.getElementById('item1');
if(s!= null)
{
alert('not null') //if object not == null
}
}
This is the error I am getting in IE –
Message: Object expected
Why do you get the domNode, if it already fires the function? Wouldn’t the
onChangecould not get fired at all, if the domNode would benull(didn’t exist)?How about this:
HTML
JS