By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,481 Members | 3,170 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,481 IT Pros & Developers. It's quick & easy.

Question related to <tbody> tag

P: 68
Hi,
I wanted to know how to access a particular column of a table.

Suppose the table has the following columns.
Name University Age Grades

Now, I want to access the cells of the Age column.
I have this piece of code, but I'm not able to access the column i want to access.

Expand|Select|Wrap|Line Numbers
  1. function ShowLogs(opt, num)
  2.   {
  3.      var tab = document.getElementById('Table');
  4.      var numRows = tab.children.length;
  5.      var tabChild = tab.firstChild;
  6.  
  7.      for (var i = 0; i < numRows; i++) {
  8.          tabChild.style.display = '';
  9.          if (opt.value != 'All' && tabChild.id != opt.value) {
  10.              tabChild.style.display = 'none';
  11.          }
  12.          tabChild = tabChild.nextSibling;
  13.      }
  14.   }
  15.  
the <tbody> definition is as follows


[HTML]<tbody id="Table">

<table border="1">
<tr>
<td>Name</td><td>Uni</td><td>Age</td><td>Grades</td>
</tr>
<tr>
<td>A</td>
<td>DSFSDF</td>
<td>45</td>
<td>SDFSD</td>
</tr>
<tr>
<td>B</td>
<td>DSFSDF</td>
<td>23</td>
<td>SDFSD</td>
</tr>

</table>
</tbody>
[/HTML]

Can Any1 help me with this problem?


Thanks,


Ravi
Feb 5 '08 #1
Share this Question
Share on Google+
1 Reply


100+
P: 428
Move your tbody inside the table- a tbody is a collection of rows.
Feb 5 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.