When a user clicks a row in a Table, I am trying to get the index of that row within the table.
When I get the index of the row I want to assign it to to hidden field so that I can process it on the server.
Current attempt is
var theCell, theRow, theTab;
// get the row that was clicked
if (!e) var e = window.event;
if (e.target) theCell = e.target;
else if (e.srcElement) theCell = e.srcElement;
if (theCell.nodeType == 3) // defeat Safari bug
theCell = theCell.parentNode;
theRow = theCell.parentNode;
theTab = theRow.parentNode
var rows = theTab.getElementsByTagName("tr")
var max = rows.length
var row
var index = 0
for (index=0; index<max-1; index++)
{
row = rows[index]
if (row = theRow)
{
alert(index)
return;
}
}
Can any one help on this.
When I get the index of the row I want to assign it to to hidden field so that I can process it on the server.
Current attempt is
var theCell, theRow, theTab;
// get the row that was clicked
if (!e) var e = window.event;
if (e.target) theCell = e.target;
else if (e.srcElement) theCell = e.srcElement;
if (theCell.nodeType == 3) // defeat Safari bug
theCell = theCell.parentNode;
theRow = theCell.parentNode;
theTab = theRow.parentNode
var rows = theTab.getElementsByTagName("tr")
var max = rows.length
var row
var index = 0
for (index=0; index<max-1; index++)
{
row = rows[index]
if (row = theRow)
{
alert(index)
return;
}
}
Can any one help on this.