B
Bart van Deenen
Hi all
I have a script where I dynamically create multiple inputs and selects
from a script. The inputs and selects must have an associated onchange
handler.
I have the script working fine on Firefox, Safari and Konqueror, but the
onchange event just doesn't fire on IE6.
Firefox's javascript console shows no errors, and the IE script debugger
shows nothing. onchange is not triggered.
Can anyone provide some information on how to solve this issue? I have
provided a complete html page that shows the problem below.
Thanks
Bart
========================================================
<html>
<head>
<title>onChange problems</title>
</head>
<body>
<script>
function onchange_handler(el)
{
alert(el+", value="+ el.options[el.selectedIndex].value );
}
function new_select()
{
f=new Array( "a", "b", "c" );
var select =document.createElement("select");
var attr;
el=document.getElementById("here");
var parent=el.parentNode;
parent.insertBefore(select,el);
attr = document.createAttribute("onchange");
attr.nodeValue='onchange_handler(this)';
select.setAttributeNode(attr);
for(i in f){
select.options = new Option(f);
}
}
</script>
<p>Click this to create <button onclick='new_select()' >new
select</button>.
Then select something to check onchange handler.
<p id='here' />
</body>
</html>
I have a script where I dynamically create multiple inputs and selects
from a script. The inputs and selects must have an associated onchange
handler.
I have the script working fine on Firefox, Safari and Konqueror, but the
onchange event just doesn't fire on IE6.
Firefox's javascript console shows no errors, and the IE script debugger
shows nothing. onchange is not triggered.
Can anyone provide some information on how to solve this issue? I have
provided a complete html page that shows the problem below.
Thanks
Bart
========================================================
<html>
<head>
<title>onChange problems</title>
</head>
<body>
<script>
function onchange_handler(el)
{
alert(el+", value="+ el.options[el.selectedIndex].value );
}
function new_select()
{
f=new Array( "a", "b", "c" );
var select =document.createElement("select");
var attr;
el=document.getElementById("here");
var parent=el.parentNode;
parent.insertBefore(select,el);
attr = document.createAttribute("onchange");
attr.nodeValue='onchange_handler(this)';
select.setAttributeNode(attr);
for(i in f){
select.options = new Option(f);
}
}
</script>
<p>Click this to create <button onclick='new_select()' >new
select</button>.
Then select something to check onchange handler.
<p id='here' />
</body>
</html>