This is a discussion on "Get value from specific cells" within the JavaScript Forum section. This forum, and the thread "Get value from specific cells are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Get value from specific cells
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Hi! I wish to get the value from a cell that specifically click by a user. I attach the script over here. For example, when i click on the first cell it should return "click 1" and if click on second cell should return "click 2". Anyone can help me? Thanks in advance.
<HTML> <HEAD> <TITLE> New Document </TITLE> <script type="text/javascript"> var editwindow = undefined; function getcell(e){ e=window.event; var tgt = e.target || e.srcElement; while (tgt && !tgt.cells) {tgt = tgt.parentNode;} alert(tgt.rowIndex); alert(document.getElementById("mytable").cells[tgt.rowIndex].innerHTML); //getting specific row } </script> </HEAD> <BODY> <p><p> <TABLE border= '1' > <TBODY id="mytable" onclick="getcell(event)"> <tr ><td>click 1</td> <td >click 2</td> <td >click 3</td> </tr> <tr ><td>click 4</td> <td >click 5</td> <td >click 6</td> </tr> </TABLE> </BODY> </HTML> |
|
|
![]() |
| Tags |
| dynamic tables |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Loading specific flash movies for specific pages | koonkle | Flash & Multimedia Forum | 3 | May 22nd, 2007 17:23 |
| Table Cells | magiccupcake | Web Page Design | 5 | Jan 23rd, 2007 01:07 |
| Switching images in cells... | Kingcobra220 | JavaScript Forum | 2 | Sep 3rd, 2006 22:33 |
| Table help with borders of cells... | andrewsco | Web Page Design | 2 | Jun 21st, 2006 22:10 |
| table cells | benbacardi | Web Page Design | 3 | Apr 15th, 2004 15:56 |