| Author: Neetu 27 Sep 2009 | Member Level: Diamond | Rating:  Points: 2 |
Hi Dear. Try this code. wil get the values from the cell of table.
<html> <body> Click in any cell to view the cellIndex & value of cell. <table id="myTable" border=2 cols="3"> <tr> <th id="th1" onclick="function1(this);">Header 1</th> <th id="th2" onclick="function1(this);">Header 2</th> <th id="th3" onclick="function1(this);">Header 3</th> </tr> <tr> <td id="td1" onclick="function1(this);">Cell1</td> <td id="td2" onclick="function1(this);">Cell 2</td> <td id="td3" onclick="function1(this);">Cell 3</td> </tr> </table> <br>
<script language="JavaScript"> function function1(elem) { alert("Cell Index :"+ elem.innerText); alert("Cell Index :"+ elem.cellIndex); } </script> </body> </html>
dont forget to rate this.
regards Neetu
|
| Author: Sumit Kr Verma 09 Oct 2009 | Member Level: Silver | Rating:  Points: 2 |
hi,
give any name to every column and row in the table and then try it.
Thanks & Regards
Sumit Kr. Verma
|