From: Angel on
Thanks a ton for all the help

I have a question more. How do I find the row number of a specific
element in a table

The following HTML sample works perfect in IE. On click of the
checkboxes, I am displaying the row number and its column number. How
do I manage the same in Firefox

<html>
<head>
<script language="javascript">
function selectedRow(object,cNumber)
{
while (object.tagName != 'TR')
{
object = object.parentNode;
}
RowNumber = object.rowIndex;
cellNumber = cNumber;
alert(RowNumber + " : " + cellNumber)
}

</script>
</head>

<body>
<table width="20%" border="1" cellpadding="0" cellspacing="0"
bordercolor="#CCCCCC" id=myTable name=myTable>
<tr id="1">
<td width="28%"><input name="r1c1" type="checkbox" id="r1c1"
onClick="selectedRow(this.parentElement,this.parentNode.cellIndex)">
R1, C1</td>
<td width="32%"><input name="r1c2" type="checkbox" id="r1c2"
onClick="selectedRow(this.parentElement,this.parentNode.cellIndex)">
R1, C2</td>
</tr>
<tr id="1">
<td><input name="r2c1" type="checkbox" id="r2c1"
onClick="selectedRow(this.parentElement,this.parentNode.cellIndex)">
R2, C1</td>
<td><input name="r2c1" type="checkbox" id="r2c1"
onClick="selectedRow(this.parentElement,this.parentNode.cellIndex)">
R2, C1</td>
</tr>
</table>
</body>
</html>

From: Martin Honnen on


Angel wrote:


> onClick="selectedRow(this.parentElement,this.parentNode.cellIndex)">

Use parentNode only, not parentElement and Mozilla and other browsers
will do as parentNode is defined in the W3C DOM while parentElement is a
left over from IE 4 times.

--

Martin Honnen
http://JavaScript.FAQTs.com/