[thelist] DOM Javascript - childNodes

Mark Howells mark at mark.ac
Thu Dec 18 02:36:20 CST 2003


>>> I'm coding a function to join several HTML forms together on a page 
>>> and submit them as one, using DOM Javascript.  I parse through the 
>>> childNodes of the main forms, then copy the lot into a new form and 
>>> submit it.
>>
>> Why not move them? It's as simple as appending them to the new form, 
>> they will be automatically removed from their original position.
>
> The problem I'm having isn't creating the new form, that's working 
> fine and I don't want to change or delete the source forms.  The 
> problem is that I want to ensure that the target form is empty before 
> I start copying elements over.  I need to do this to ensure that I 
> don't end up with multiple fields with the same name, if the copy 
> function is run more than once before the form is submitted.

A further result, just found: I have integrated a loop which clears all 
of the childNodes, but it would appear that even if all childNodes of 
the form have been deleted (this IS the case), the form.elements array 
is still populated.  Thus, when I copy nine form elements over four 
times using appendChild, then delete them using removeChild, the end 
result is a form with no childNodes but 36 form elements.

Huh?

Regards
Mark Howells
http://www.mark.ac/



More information about the thelist mailing list