...

View Full Version : dynamically appending child at a specified position....?



murali1983
12-28-2006, 05:23 PM
Hi

i want to dynamically add rows to my table body using javascript, which am able to do. but there is a problem.

for ex.
three rows
1
2
3

if i delete second row
1
3
if i want to add one more row.., then it should be row 2 with number 2.
---------------------------------------------
var totChkTable = document.getElementById('TABLE');
row=totChkTable.tBodies[0].appendChild(document.createElement('<tr >'));
..
....
cell=document.createElement('td');
---------------------------------------------

In each row ther r 6 colums, so i need a way where i can append my child in b/w.

thnx
murali

j9ine
12-28-2006, 05:45 PM
You can use the insertBefore() method.


var totChkTable = document.getElementById('TABLE');
var rows = totChkTable.getElementsByTagName('tr');
totChkTable.tBodies[0].insertBefore(document.createElement('tr'),rows[1]);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum