Click here to Skip to main content
13,147,044 members (60,944 online)
Rate this:
Please Sign up or sign in to vote.
See more:

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 3-Jan-12 0:56am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

hope it helps.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

try following sample...

<?xml version="1.0" encoding="UTF-8"?>
  <script type="text/javascript" src=""></script>
  <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);
<tr><td>a1</td><td >a2</td></tr>
<tr><td >b1</td> <td>b2</td></tr>

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170915.1 | Last Updated 3 Jan 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100