By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,665 Members | 1,251 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,665 IT Pros & Developers. It's quick & easy.

deleteRow leaves empty <TR></TR> pairs

P: n/a
In both IE6 and Netscape 7:

insertRow method of tbody is behaving as expected:
- inserts a new row
- increases tbody.rows.length

BUT deleteRow is not doing the opposite.

It DOES delete the row, but it adds a <TR></TR> pair just before the
</TBODY> and that leaves the tbody.rows.length count unchanged.

Demo page at http://www.btinternet.com/~geddes.winster/drtable.htm

What am I doing wrong?

John Geddes
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"John Geddes" <jo**@starmarkassociates.co.uk> wrote in message
news:70**************************@posting.google.c om...
In both IE6 and Netscape 7:

insertRow method of tbody is behaving as expected:
- inserts a new row
- increases tbody.rows.length

BUT deleteRow is not doing the opposite.

It DOES delete the row, but it adds a <TR></TR> pair just before the
</TBODY> and that leaves the tbody.rows.length count unchanged.

Demo page at http://www.btinternet.com/~geddes.winster/drtable.htm


Snippet of your code:
function delRow(tabName){
var thisBody=document.getElementById(tabName);
var origLength=thisBody.rows.length;
var tr= thisBody.insertRow(thisBody.rows.length); //Why this?
var rowNo=document.aForm.t1.value;
if (thisBody.rows[rowNo]){
thisBody.deleteRow(rowNo);
var tb2=document.getElementById(tabName);
alert("attempted to delete row index="+ rowNo+ " from
"+tabName+String.fromCharCode(10)+"rowCount changed from "+origLength+" to
"+thisBody.rows.length+String.fromCharCode(10)+"CH ECK length with redefined
tbody: "+tb2.rows.length);
} else {
alert("no row in "+tabName+"with index "+rowNo);
}
}
Try get rid of statement:

var tr= thisBody.insertRow(thisBody.rows.length);

Jul 20 '05 #2

P: n/a
Looks like I copied the addRow script and forgot to kill that line.

Must be spending too long staring at the screen.

Thanks so much.

John Geddes

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.