JavaScript Document (8) Events (8) ExtJS (5) Strings (3)
Exchange Links About this site Links to us 
|
Obtain the number of rows in a table
8 comments. Current rating: (4 votes). Leave comments and/ or rate it.
Question: How can I obtain the number of rows in an HTML table using javascript?
Answer: The following code assumes that your table has the ID 'MyTable'
 | |  | | <script language="JavaScript">
<!--
var oRows = document.getElementById('MyTable').getElementsByTagName('tr');
var iRowCount = oRows.length;
alert('Your table has ' + iRowCount + ' rows.');
</script>
| |  | |  |
Comments:
|
|
|
|
It is great, Thank u
|
|
|
|
|
wicked, cheers
|
|
|
|
|
Simple and perfect for me today. thankyou.
|
|
|
|
|
thank you
|
|
|
|
|
Just what I needed. Thanks very much.
|
|
|
|
|
Very simple and helful! Thanks!
In one row:
alert(document.getElementById('MyTable').getElementsByTagName('tr').length);
|
|
|
|
|
Thanks, useful
|
|
|
|
|
Thanks for your great help :)
|
|