Andrew Poulos wrote:
VK wrote:
I'm trying to append a form element to a form
It seems to work fine in FF but IE fails silently.
...
ff.value = values[i];
frm.appendChild(ff);
if (frm.normalize) {frm.normalize();}
...
The last statement will re-validate form elements in the collection.
Thanks but it made no difference.
If I put an alert immediately before and another immediately after the
appendChild call he first alert displays but not the second!
Andrew Poulos
Sorry, and who will add the form itself? :-)
And you have to do it *only* after onload when the DOM structure is
fully rendered, otherwise appendChild's will not find any parents.
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script type="text/javascript">
function test() {
var frm = document.createElement("FORM");
frm.method = "post";
frm.action = "include/writeData.asp";
var ff, values = ["foo", "bar", "qwerty", "eggog"];
for (var i=0; i<values.length; i++) {
ff = document.createElement("INPUT");
ff.type = "text";
ff.name = "field"+i;
ff.id = "field"+i;
ff.value = values[i];
frm.appendChild(ff);
}
document.body.appendChild(frm);
frm.normalize();
}
window.onload = test;
</script>
</head>
<body bgcolor="#FFFFFF">
</body>
</html>