On 8 Oct 2004 13:05:46 -0700, hari <si***********@tcs.com> wrote:
I want to retreive the row number of a cell in the table when the
mouse is over that cell.
Can any one help?
With modern, DOM-supporting browsers, you can obtain the parent of the
table (the row), and get the row index of that via a property.
<tr>
<td onmouseover="getRowIndex(this);">
...
function getRowIndex(cell) {
var row = cell.parentNode;
if(row && 'undefined' != typeof row.rowIndex) {
return row.rowIndex; // or row.sectionRowIndex
}
}
The difference between rowIndex and sectionRowIndex is that the former
runs throughout the entire table. The latter restarts at the beginning of
each table section (TBODY, THEAD and TFOOT). Indicies are zero-order.
Hope that helps,
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.