...

View Full Version : IE onchange does not work with function



idipous
10-17-2008, 04:20 PM
Hello everybody,

I have written this script in order to produce a new textbox when the previous one is changed. Tha problem is that when I try to run the same code on IE it does not work as it does in Firefox.


<script type="text/javascript" language="javascript">

var n=0;
var lastInputElement=null;
function createTextBox(creator)
{
if(creator!=lastInputElement)
{
return;
}

n++;

var ele= document.getElementById('prime');
addNode(ele,n);
}

function addNode(ele,n)
{
var child=document.createElement('div');
child.setAttribute('id', 'generic' + n);
ele.appendChild(child);

var input = document.createElement('input');
input.setAttribute('type', 'text');
input.setAttribute('name', 'generic' + n);
input.setAttribute('onChange', 'createTextBox(this)' );


child.appendChild(input);

lastInputElement = input;

}

</script>
</head>
<body onLoad="createTextBox()">
<form >
<div id="prime"></div><input name="Save" type="submit" id="Save" value="Save" />
</form>
</body>
</html>

Any ideas?
Thanks in advance
idipous

rnd me
10-17-2008, 04:27 PM
input.onchange =function(){createTextBox(this);}

idipous
10-23-2008, 07:40 PM
I managed to figure it out but thanks anyway for the reply



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum