insertRow() and deleteRow() not functioning

VERIFIED INVALID

Status

()

Core
DOM: Core & HTML
VERIFIED INVALID
16 years ago
9 years ago

People

(Reporter: Eric Rasmussen, Assigned: jst)

Tracking

Trunk
x86
Windows 2000
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

16 years ago
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>
var tr = table1.insertRow();

there's a number missing!
Status: UNCONFIRMED → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → INVALID

Comment 2

16 years ago
using insertRow() with out arguments is incorreect. It should be used as
insertRow(index).
then it's valid - never heared that and also can't found it in the spec..
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---

Comment 4

16 years ago
Kai,

what part of my comment suggested this is valid ;)
Status: UNCONFIRMED → RESOLVED
Last Resolved: 16 years ago16 years ago
Resolution: --- → INVALID
good question, maybe I read another comment? ;)
verifying
Status: RESOLVED → VERIFIED
(Reporter)

Comment 6

16 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

13 years ago
*** Bug 286184 has been marked as a duplicate of this bug. ***
*** Bug 310661 has been marked as a duplicate of this bug. ***

Updated

9 years ago
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.