Page 1 of 1

[SOLVED] Add Input Element to a Form

Posted: Thu Jun 23, 2005 4:28 am
by anjanesh
I have

Code: Select all

var oInput = document.createElement(&quote;INPUT&quote;);
// Set the attributes
How do I add it to a form ?
Like document.getElementById("frm").addElement(oInput);

Thanks

Posted: Thu Jun 23, 2005 5:03 am
by phpScott
one way is to

Code: Select all

document.getElementById('someElementName').innerHTML=newElement
be careful though as this will over write everything with someElementName

innerHTML is what you want

Posted: Thu Jun 23, 2005 5:06 am
by anjanesh

Code: Select all

frm.appendChild(oInput);
works in IE and FF.

If there are some issues with this please let me know.
Seems to be doing to job though.