Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert rows dynamically in a table

Status
Not open for further replies.

thatts

Programmer
Sep 6, 2007
3
US
Hi,


I need to insert rows dynamically in a table. I know I can do that with
following code.

var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;

var row = tbl.insertRow(lastRow);

// left cell
var cellLeft = row.insertCell(0);
textNode = document.createTextNode("2828233665" + rownum++);
cellLeft.appendChild(textNode);

But what I want is not create cells and add it, but to add the whole
row with content something like this.

var row = tbl.insertRow(lastRow);
row.setContent("<td>"1"</td><td>"2"</td>")

In other words I get the whole row text and I want to insert that as
row, insted of column by column. Couldn't find a way to do that.

Any thoughts ???

_Pete

 
I have existing code that pushes (ajax) row by row information to the client. So I have to parse and split the cells before inserting it in the table. If I could directly replace the rows, it would be less over head.

Thanks
_pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top