Click to See Complete Forum and Search --> : is rowIndex correct


Webskater
04-19-2005, 03:53 AM
I read up on the DOM and rowIndex gets a mention. But:

function changeit(fred,jim,jack,event)
{
if (document.all)
{
alert(fred + ',' + jim + ',' + jack);
event.srcElement.className = "norm"; //just to prove the event element has been detected okay (it has)
var rowNo = event.srcElement.parentElement.rowIndex;
alert(rowNo)
}
else
{
alert(fred + ',' + jim + ',' + jack);
event.target.className = "norm"; //just to prove the event element has been detected okay (it has)
var rowNo = event.target.parentElement.rowIndex;
alert(rowNo)
}
}

In IE the row number is displayed.
In Firefox - nothing - not even an empty alert box.

Any idea how I can find out which row number of a table the element which fires an event is in in Firefox?

Thanks for any help.

7stud
04-19-2005, 04:45 AM
Any idea how I can find out which row number of a table the element which fires an event is in in Firefox?
1)You can name your rows cleverly, e.g. row0, row1, row2, etc and then get the name of the row and use charAt() to get the 4th character.

2) You can compare the this keyword to the elements of the rows[] array.

Why do you need the row number? Are you going to display it?