Closed
Bug 157578
Opened 22 years ago
Closed 22 years ago
insertRow() and deleteRow() not functioning
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
VERIFIED
INVALID
People
(Reporter: eric, Assigned: jst)
References
Details
insertRow() and deleteRow() on TABLE and TBODY are not working. According to the W3C DOM Level 1, both TABLE and TBODY should support the insertRow() and deleteRow() methods. I am using the following code to add a new table row to an existing table: <html> <head> <title>Test of Tables</title> <script language="JavaScript"> var cellNum = 1; function insertRow() { var table1 = document.getElementById( "Table1" ); var tr = table1.insertRow(); var td = document.createElement( "TD" ); td.innerHTML = "This is table cell " + cellNum++; tr.appendChild( td ); updateRowCount(); } function deleteRow( index ) { var table1 = document.getElementById( "Table1" ); table1.tBodies[ 0 ].deleteRow( index ); updateRowCount(); } function updateRowCount() { var table1 = document.getElementById( "Table1" ); var rowCount = document.getElementById( "RowCount" ); rowCount.innerHTML = table1.tBodies[ 0 ].rows.length; } </script> </head> <body> <span id="RowCount">1</span> <p> <table id="Table1" width="50%" border="1" cellpadding="4" cellspacing="0"> <thead> <tr> <td>This is a table header</td> </tr> </thead> <tbody> <tr> <td>This is table cell 0</td> </tr> </tbody> </table> <p> <input type="button" value="Insert New Row" onclick="insertRow();"> <p> <input type="button" value="Delete 4th Row" onclick="deleteRow( 3 );"> </body> </html>
Comment 1•22 years ago
|
||
var tr = table1.insertRow(); there's a number missing!
Status: UNCONFIRMED → RESOLVED
Closed: 22 years ago
Resolution: --- → INVALID
Comment 2•22 years ago
|
||
using insertRow() with out arguments is incorreect. It should be used as insertRow(index).
Comment 3•22 years ago
|
||
then it's valid - never heared that and also can't found it in the spec..
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Comment 4•22 years ago
|
||
Kai, what part of my comment suggested this is valid ;)
Status: UNCONFIRMED → RESOLVED
Closed: 22 years ago → 22 years ago
Resolution: --- → INVALID
Comment 5•22 years ago
|
||
good question, maybe I read another comment? ;) verifying
Status: RESOLVED → VERIFIED
Reporter | ||
Comment 6•22 years ago
|
||
Sorry guys... That's what I get by following the MSDN Library documentation (Microsoft's documentation). I expected that when they say their insertRow() method is implemented according to the W3C spec, I wouldn't need to check the spec myself. But this *is* Microsoft, and it seems they are not too good at following specifications in Internet Exploder. :-) I'll look at the W3C spec directly in the future. Thanks for the quick response!
Comment 7•20 years ago
|
||
*** Bug 286184 has been marked as a duplicate of this bug. ***
Comment 8•19 years ago
|
||
*** Bug 310661 has been marked as a duplicate of this bug. ***
Component: DOM: HTML → DOM: Core & HTML
QA Contact: stummala → general
You need to log in
before you can comment on or make changes to this bug.
Description
•