468,244 Members | 1,875 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,244 developers. It's quick & easy.

deleteRow leaves empty <TR></TR> pairs

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
2 3414
"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
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.

Similar topics

4 posts views Thread by El Diablo | last post: by
1 post views Thread by prefersgolfing | last post: by
3 posts views Thread by jack | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.