
Getting row/column index of HTML TABLE cell
Hello,
Here is a little function I wrote to capture just what you are looking for.
I used it to create an updateable table. You may have to tweek it a little
for you purposes. Sorry about the formatting on paste from notepad. :(
Ted White
Intelesoft
function TblRecordsOnClick()
{
var tempText;
var cellWidth;
if (event.srcElement.tagName == "TD")
{
if (curRow != 0)
{
tempText = EditBox.value;
tblRecords.rows(curRow).cells(curCol).innerHTML = "";
tblRecords.rows(curRow).cells(curCol).innerText = tempText;
}
curRow = event.srcElement.parentElement.rowIndex;
curCol = event.srcElement.cellIndex;
tempText = tblRecords.rows(curRow).cells(curCol).innerText;
cellWidth = tblHeader.rows(0).cells(curCol).style.width;
tblRecords.rows(curRow).cells(curCol).innerText = "";
tblRecords.rows(curRow).cells(curCol).insertAdjacentHTML("BeforeEnd",
"<INPUT ID='EditBox' TYPE='Text' VALUE='" + tempText + "' STYLE='width:" +
cellWidth + ";'>");
}
Quote:
}
>Is it possible, in connection with the ondblclick event in a table cell, to
>retrive the row and column number of the cell clicked?
>I am working with IE 4.0; it would be OK to use IE-specific additions, as I
>am building an in-house report tool that will only be viewed by IE clients.
>I am new to VBScript/the IE document object model. I have looked through
the
>documentation available to me, but can't find any answer there.
>Hans Olav Husum