ja********@willasrari.com wrote:
>
<tr>
<td><input type="hidden" id='itemId_46' value='1' /></td>
<td>1</td>
<td>0.2</td>
<td>0.3</td>
</tr>
<tr>
<td><input type="hidden" id='itemId_55' value='2' /></td>
<td>2</td>
<td>0.201</td>
<td>0.303</td>
</tr>
My question has now grown to this: Is it possible to get the
row[index] based on finding the element itemId_55?
Every TR element has a property rowIndex reflecting its index value in
the table.rows collection. Similarly, every TD element has a property
cellIndex reflecting its cell index in the table.rows[N].cells
collection.
So this is the code you need:
hiddenElement = document.getElementById("itemId_55");
rowIndex = hiddenElement.parentNode.parentNode.rowIndex;
where hiddenElement is the hidden <INPUTelement whose position we are
seeking.
hiddenElement.parentNode --points to the parent TD element
hiddenElement.parentNode.parentNode --points to the parent TR element
from here:
hiddenElement.parentNode.parentNode.rowIndex yields the rowIndex
through which we can access the row from the table.rows collection.
or here is a one line code for accessing the rowIndex:
document.getElementById("itemId_55").parentNode.pa rentNode.rowIndex;