I need to add elements dynamically to a Form in JavaScript. I thought the addChild
method would be useful and I tried the following:
var objForm = document.getElementById("idForm");
objForm.addChild(element);
However, it produces an error saying the object doesn't have the method.
How can I add elements to a form using Javascript?
innerText
orinnerHTML
property that you might be able to use. I'm not sure which one you need to use and there are some compatibility issues with one of them. However, if you want to be adding form elements all the time you may have to mess around and hold all of them in variables so that you don't write over them in the next edit. You will need to keep track of variables. I think that will work but there is probably a better method that's a bit neater! — rtm223