W
webdev
Hi,
Code below dynamically adds an input box to a form, creating a new name
attribute as it goes... (many thanks to Martin Honnen for getting me this
far ;0) Problem is - in IE5.5 only the first form field (the hard-coded one)
is recovered from the form, while with Mozilla/Firefox all fields are.
The alert() just shows that the newly created element has no name in IE. Can
anyone offer help with this bizarre problem (I thought any old rubbish would
run in IE - even mine!)
Regards
Rae MacLeman
----------------------------------------------------------------------------
---------
<HTML>
<HEAD>
</HEAD>
<SCRIPT LANG=Javascript>
<!--
var gCount=1;
function DoChange() {
var objNewName, objBR;
gCount++;
objNewName = document.createElement('INPUT');
objNewName.setAttribute('NAME', 'fname'+gCount);
alert('object name = '+objNewName.name);
objNewName.setAttribute('ID', 'name'+gCount);
objBR = document.createElement('BR');
document.getElementById("names").appendChild(objNewName);
document.getElementById("names").appendChild(objBR);
delete objNewName;
delete objBR;
}
//-->
</SCRIPT>
<BODY>
<form action="mozilla_test2_handler.asp" method="POST">
<div id="names" name="names">
<input id="fname1" name="fname1" type="text"><br>
</div>
<INPUT TYPE=button ONCLICK=DoChange() VALUE='Add name'><input
type="submit"></form>
</BODY>
</HTML>
Code below dynamically adds an input box to a form, creating a new name
attribute as it goes... (many thanks to Martin Honnen for getting me this
far ;0) Problem is - in IE5.5 only the first form field (the hard-coded one)
is recovered from the form, while with Mozilla/Firefox all fields are.
The alert() just shows that the newly created element has no name in IE. Can
anyone offer help with this bizarre problem (I thought any old rubbish would
run in IE - even mine!)
Regards
Rae MacLeman
----------------------------------------------------------------------------
---------
<HTML>
<HEAD>
</HEAD>
<SCRIPT LANG=Javascript>
<!--
var gCount=1;
function DoChange() {
var objNewName, objBR;
gCount++;
objNewName = document.createElement('INPUT');
objNewName.setAttribute('NAME', 'fname'+gCount);
alert('object name = '+objNewName.name);
objNewName.setAttribute('ID', 'name'+gCount);
objBR = document.createElement('BR');
document.getElementById("names").appendChild(objNewName);
document.getElementById("names").appendChild(objBR);
delete objNewName;
delete objBR;
}
//-->
</SCRIPT>
<BODY>
<form action="mozilla_test2_handler.asp" method="POST">
<div id="names" name="names">
<input id="fname1" name="fname1" type="text"><br>
</div>
<INPUT TYPE=button ONCLICK=DoChange() VALUE='Add name'><input
type="submit"></form>
</BODY>
</HTML>