In JavaScript, how can I add a row dynamically to a table? On a JavaScript event I want to create a similar row and append to the table.
tried all sorts of searches today, made use of sources : http://www.mredkj.com/tutorials/tablebasics3.html and http://www.mredkj.com/tutorials/tableaddcolumn.html
here's the result of my logic research, it's working now
function addRow(id)
{ var x=document.getElementById(id).tBodies[0]; //get the table
var node=t.rows[0].cloneNode(true); //clone the previous node or row
x.appendChild(node); //add the node or row to the table
}
function delRow(id)
{ var x=document.getElementById(id).tBodies[0]; //get the table
x.deleteRow(1); //delete the last row
}
NOTE1: my table contained a cell that had a textbox + a label in it per table row(tr).
NOTE2: in a row, there were multiple (td)'s that had a label + textbox