garry27
12-16-2006, 06:50 PM
hi,
i'm trying to loop through a table to find the next row with empty td elements. i've put alert events along the way to try and debug it (normally i'd have (txt=='') in the if control structure.
the first alert popup says [object text], the second says undefined. how do i change the code so nextEmptyRow reads the next empty row's index or id?
insRow:function(elm){
var tbl = elm.parentNode;
for (var i=0;i<tbl.rows.length;i++) {
var currTr = tbl.rows[i];
var td = currTr.firstChild;
var txt = td.firstChild;
alert(td);
if (txt == '3'){
var nextEmptyRow = '3';
break;
}
}
alert(nextEmptyRow);
i'm trying to loop through a table to find the next row with empty td elements. i've put alert events along the way to try and debug it (normally i'd have (txt=='') in the if control structure.
the first alert popup says [object text], the second says undefined. how do i change the code so nextEmptyRow reads the next empty row's index or id?
insRow:function(elm){
var tbl = elm.parentNode;
for (var i=0;i<tbl.rows.length;i++) {
var currTr = tbl.rows[i];
var td = currTr.firstChild;
var txt = td.firstChild;
alert(td);
if (txt == '3'){
var nextEmptyRow = '3';
break;
}
}
alert(nextEmptyRow);