dynamically add row to middle of table
Posted on 2007-03-28
I think I know how but when I run
var tbl = document.getElementById('myTable');
var lastRow = tbl.rows.length;
lastRow will always be 0 even though there are like 8 rows in my table. I stepped through it with a debugger (venkman) and it's referencing the right table because innerHTML is correct. Is this "normal" behavior or should the whole table load correctly with the document.getElementById command.
var row = tbl.insertRow(lastRow);
will add a row to the end of the table and putting a -2 sign before it will produce an error.