Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have an html table with 10 columns as fields(TC1,TC2.....TC10) and 10 rows (R1, R2,........R10). This able contains only pass and fail data as per the combination of TC1 vs R1, TC1 vs R2 and so on.

When a user clicks on any of the cell with value as Fail.
I need to retrieve the value of the </brow and column number of that cell. This click could be on any call with value as Fail.

I need the row and column values to do further calculations
Posted

check these links..

tables cell from javascript[^]

how do you access rows columns html table[^]

access Table cells content Firefox[^]

write the javascript function discussed in above links and call that function from OnClick event of Table cell.

HTML
<table><tr><td id="tdid"  önclick="funcName()"></td></tr></table>


hope it helps.
 
Share this answer
 
v2
try following sample...


XML
<?xml version="1.0" encoding="UTF-8"?>

<html>
  <head>
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  </head>
<body>

  <script type="text/javascript">
$(document).ready(function() {
    $('td').click(function() {
        var col = $(this).parent().children().index($(this));
        var row = $(this).parent().parent().children().index($(this).parent());
        alert('Row: ' + row + ', Column: ' + col);
    });

});
</script>

<table>
<tr><td>a1</td><td >a2</td></tr>
<tr><td >b1</td> <td>b2</td></tr>
</table>
  </body>
</html>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900