Contents Index Topic Contents | ||
Previous Topic: plugins Next Topic: rules |
rows
Description
Retrieves a collection of rows (TR elements) in the table. The scope of this collection is for the THEAD, TBODY, or TFOOT of the table. In addition, there is also a rows collection for the TABLE, which contains all the rows for the entire table. A row that appears in one of the table sections also appears in the rows collection for the TABLE. The TR has two index properties, "rowIndex" and "sectionRowIndex", which indicate where, with respect to the rows collection for the given table section, and where with respect to the rows collection for the table in which the TR appears.
Syntax
object.rows(index)
Parameter Description object A TABLE, TBODY, THEAD, or TFOOT element. index Optional. An integer or a string specifying the index value of the element to retrieve. Integer indexes are zero-based, meaning the first element in the collection has index 0. A string index is valid only if the string is an identifier of at least one element in the document. Remarks
If duplicate identifiers are found, a collection of those items is returned. Collections of duplicates must subsequently be referenced by ordinal position.
Example
The following example uses the rows and cells collections to insert a number into each cell of the table.
<HTML> <SCRIPT LANGUAGE="JScript"> function numberCells() { var count=0; for (i=0; i < document.all.mytable.rows.length; i++) { for (j=0; j < document.all.mytable.rows(i).cells.length; j++) { document.all.mytable.rows(i).cells(j).innerText = count; count++; } } } </SCRIPT> <BODY onload="numberCells()"> <TABLE id=mytable border=1> <TR><TH> </TH><TH> </TH><TH> </TH><TH> </TH></TR> <TR><TD> </TD><TD> </TD><TD> </TD><TD> </TD></TR> <TR><TD> </TD><TD> </TD><TD> </TD><TD> </TD></TR> </TABLE> </BODY> </HTML>Applies To
Property
Methods
Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.