[thelist] Dynamic form fields with Javascript

Mark Howells mark at mountain.ch
Wed Jan 23 04:55:53 CST 2002


Does anyone know if it's possible to dynamically add form fields to a 
form using Javascript? I'm trying to make a function that will take all 
of the form fields from forms on other layers on the page and add them 
all to a single form in the page body.

Something like

document.forms["main"].elements[document.forms["main"].elements.length+1].name=
"newField";
document.forms["main"].elements["newField"].type="hidden";
document.forms["main"].elements["newField"].value="newValue";

(According to Murphy's Law, this doesn't work.)

Thanks and regards
Mark Howells
<http://www.mark.ac/evl>





More information about the thelist mailing list