Click to See Complete Forum and Search --> : A copy of an element


Babak
02-07-2003, 02:51 PM
I want to create (using Javascript) a copy of an element and it's children, change the ids in copy and append it to my document.

to be precise I want to have my current table and new data entered in it's Input, intact and add a row like the first row of the table to the end.

Webskater
02-07-2003, 04:40 PM
Teh code below adds a new row to a table, a new cell and writes something in the cell. Don't know if it works in Netscape. Does work in IE.

function AddRow()
{
newrow = tablename.insertRow()
lastrow = tablename.rows.length - 1;
tablename.rows[lastrow].insertCell();
tablename.rows[lastrow].cells[0].innerText = 'New row here!'
}

When you add the cells you could loop to add as many cells as you need and popolate them with whatever child objects you want to put in.

khalidali63
02-07-2003, 04:44 PM
It does not work in NS

:p

Cheers

Khalid