Thanks for your response.
The issue that I now encounter is this:
I have cloned my div and its elements and also assigned unique ids to each of them.Say there is a table in the original div that was supposed to be cloned.I need to make sure that only the header of this table is copied and not the remaining rows when the original div is cloned.
In order to achieve this,I write a js function as shows below that removes all the rows of the table.When I do :
var tbl = document.getElementById(ta
tbl is being returned as null.
Can this be fixed?
Thanks.
Main Topics
Browse All Topics





by: PhillipsWellnessPosted on 2008-08-04 at 11:39:11ID: 22154850
You use cloneNode(true) to make a deep copy of the div block. Then, you will loop through it and change all the IDs. Once you've changed all the element ID's, then you will append the newly cloned div block to a 'parent' with appendChild() function.
div);
See code below for example...
You'll need ot change all the ID's so you don't have ID conflicts. The name of your select box wouldn't necessarily have to change (if you want both of them submitted together as one 'element' for your form handler). But if you want them to be different, then you should change it too.
One important thing to note is that after you do cloneNode(true) you have not yet added this new div block to your document. It has to be appended to your existing document in some way. If there is an outer div block for it, then that would be as simple as
outer_div.appendChild(new_
Just make sure your id's are going to be changed before you appendChild() so you don't have any conflicts.
Hope this helps!
P.S. new_div.children[0][0] might reference the THEAD or TBODY tag. If so, then you can add another [0] to what I have below so that you are looking at the first TR inside the TBODY tag.
Let me know if you have any questions.
Select allOpen in new window