asp.net.ph

Skip Navigation Links

insertRow Method

DHTML Methods


Inserts a new empty row ( TR ) in a TABLE.

Syntax

oTR = object.insertRow ( [ iIndex ] ) 
Parameters

iIndex Optional. The row number where to insert the new row. This index starts from 0 and is relative to all the rows contained inside the table, regardless of section parentage. The default value is -1, which appends the new row to the end of the rows collection.

Return Value

Returns the newly created TR object if successful, or null otherwise.

Remarks

The new row is inserted immediately before and in the same section as the current indexth row in the table. If iIndex is equal to the number of rows, the new row is appended. In addition, when the table is empty, the row is inserted into a TBODY which is created and inserted into the table. Note however that a table row cannot be empty according to HTML 4.0 recommendation.

Inserting a row in a TFOOT, TBODY, or THEAD also adds a row to the rows collection for the TABLE.

Inserting a row in the TABLE adds a row to the rows collection for the TBODY. If specifying an index, the index should be relative to the rows collection for the element which first contains the TR. For example, calling this method for a TBODY would take an index value relative to the rows collection that is on the TBODY, not the TABLE.

Example

The following example adds a row to the TABLE.

myNewRow = document.all.myTable.insertRow ( ) 
Applies To

TABLE, TBODY, TFOOT, THEAD

See Also

insertCell, rows, rowIndex, sectionRowIndex



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note