Click here to Skip to main content
11,577,710 members (61,491 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VBScript HTML
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 3-Jan-12 0:56am
Anhsa111
Rate this: bad
good
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.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

try following sample...


<?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>
  Permalink  

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

  Print Answers RSS
0 Peter Leow 180
1 Richard MacCutchan 175
2 DamithSL 150
3 OriginalGriff 135
4 Afzaal Ahmad Zeeshan 95
0 OriginalGriff 830
1 Sergey Alexandrovich Kryukov 701
2 Abhinav S 573
3 F-ES Sitecore 420
4 Dave Kreskowiak 374


Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 3 Jan 2012
Copyright © CodeProject, 1999-2015
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