[SOLVED] Add Input Element to a Form

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

[SOLVED] Add Input Element to a Form

Post 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
Last edited by anjanesh on Thu Jun 23, 2005 5:07 am, edited 1 time in total.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post 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
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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.
Post Reply