<html> <head> <title> New Document </title> <script language="JavaScript"> <!-- var rowIndex, colIndex;function changeCell() { var oTbl = document.all.tbl_id; var objCell = event.srcElement; // get the <td> object clicked var objRow = objCell.parentElement; // get the <tr> object containing the <td> object clicked if (rowIndex == null) { rowIndex = objRow.rowIndex; //get the <tr> position in the rows collection for the table; return; } if (colIndex == null) { colIndex = objCell.cellIndex; //get the <td> position in the cells collection for the given row; oTbl.rows(rowIndex).cells(colIndex).innerHTML = "The " + (rowIndex + 1) + " Row<br>The " + (colIndex + 1) + " Column"; //set the particular value in the cell selected by cross rowIndex = null; colIndex = null; } }function window.onload() { tbl_id.onclick = changeCell; } //--> </script> </head><body> <table border=1 width="100%" id=tbl_id> <tr> <td>0</td> <td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td> <td>5</td> </tr> <tr> <td>6</td> <td>7</td> <td>8</td> </tr> </table> </body> </html>
<head>
<title> New Document </title>
<script language="JavaScript">
<!--
var rowIndex, colIndex;function changeCell()
{
var oTbl = document.all.tbl_id;
var objCell = event.srcElement; // get the <td> object clicked
var objRow = objCell.parentElement; // get the <tr> object containing the <td> object clicked if (rowIndex == null)
{
rowIndex = objRow.rowIndex; //get the <tr> position in the rows collection for the table;
return;
} if (colIndex == null)
{
colIndex = objCell.cellIndex; //get the <td> position in the cells collection for the given row;
oTbl.rows(rowIndex).cells(colIndex).innerHTML = "The " + (rowIndex + 1) + " Row<br>The " + (colIndex + 1) + " Column"; //set the particular value in the cell selected by cross
rowIndex = null;
colIndex = null;
}
}function window.onload()
{
tbl_id.onclick = changeCell;
}
//-->
</script>
</head><body>
<table border=1 width="100%" id=tbl_id>
<tr>
<td>0</td>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>6</td>
<td>7</td>
<td>8</td>
</tr>
</table>
</body>
</html>