idipous
10-17-2008, 03: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
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