...

View Full Version : count the number of rows in the table



crmpicco
01-28-2005, 12:44 PM
I would like to be able to write a function (or something) to count the number of rows in the table, I don't know how to do it, any help is appreciated.

glenngv
01-28-2005, 01:12 PM
var rowCount = document.getElementById("tableID").getElementsByTagName("TR").length;
alert(rowCount);

anil029
04-12-2011, 07:33 AM
Hi,
But this method throws a "Object Required" error and opening a new browser window.What can be the reason behind this?

Thanks,
Anil

Philip M
04-12-2011, 07:36 AM
Hi,
But this method throws a "Object Required" error and opening a new browser window.What can be the reason behind this?

Thanks,
Anil

It works just fine for me. :)

The fault, dear Brutus, lies not in the stars but .......

It is your responsibility to die() if necessary….. - PHP Manual

bullant
04-12-2011, 07:45 AM
I would like to be able to write a function (or something) to count the number of rows in the table, I don't know how to do it, any help is appreciated.


alert(document.getElementById('yourTableID').rows.length);

Kor
04-12-2011, 09:41 AM
alert(document.getElementById('yourTableID').rows.length);
It absolutely the same as glenngv posted


alert(document.getElementById('yourTableID').getElementsByTagName('tr').length);



Hi,
But this method throws a "Object Required" error and opening a new browser window.What can be the reason behind this?

Impossible.

Anyway, you have cross-posted:
http://www.codingforums.com/showthread.php?t=223824
So we should continue the discussion there. I will close this old thread, which was dug up for nothing

bullant
04-12-2011, 09:43 AM
It absolutely the same as glenngv posted
[code]


Your statement is obviously not true, again ;)

It produces the same result but is not the same code :) I just offered another option to get what the op wants.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum