insertRow Method

DHTML, HTML, & CSS

 
Click to return to the DHTML, HTML & CSS home page    
insertCell Method     isEqual Method     DHTML Methods    

insertRow Method


Creates a new row (TR) in the table, and adds the row to the rows collection.

Syntax

oTR = object.insertRow([iIndex])

Parameters

iIndexOptional. Integer that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection.

Return Value

Returns the TR element object if successful, or null otherwise.

Remarks

If you insert a row in a TFOOT, TBODY, or THEAD, you also need to add the row to the rows collection for the TABLE. If you insert a row in the TABLE, you also need to add the row to the rows collection for the TBODY. If you specify an index, the index should be relative to the rows collection for the element that first contains the TR. For example, if you call this method for a TBODY, you must specify an index value relative to the rows collection that is on the TBODY, not the TABLE.

The preferred technique for inserting a row is to add the row at the end of the rows collection. It is faster to add a row at the end of a table than somewhere in the middle. To add a row at the end of the collection, specify the -1 value, or the length of the rows collection minus 1.

Example

This example uses the insertRow method to add a row to the TABLE.

myNewRow = document.all.myTable.insertRow()

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
Version data is listed when the mouse hovers over a link, or the link has focus.

TABLE, TBODY, TFOOT, THEAD

See Also

rowIndex, rows, sectionRowIndex


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.