473,835 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Html table row count

Hi to all,

im just newbie in javascript and html dom. I just want to know how will
i get the total number of rows in a certain html table? Please help, it
will be very much appreciated. Thanks in advance.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #1
4 65910


Cris Teta wrote:

im just newbie in javascript and html dom. I just want to know how will
i get the total number of rows in a certain html table?


The W3C DOM is publically documented:
http://www.w3.org/TR/DOM-Level-2-HTML/
you will find the properties of a HTML <table> element here:
http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-64060425
So the rows property is what you are looking for which then has a
property length you can check.
As for accessing a certain HTML table that is not different from a
accessing any other certain element, if the table has an id attribute
you can use
var table = document.getEle mentById('table Id')
but of course the DOM has other ways (getElementsByT agName, childNodes,
first/lastSibling) to access nodes.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
dot
Cris Teta wrote:
Hi to all,

im just newbie in javascript and html dom. I just want to know how will
i get the total number of rows in a certain html table? Please help, it
will be very much appreciated. Thanks in advance.


The table-element has a rows collection which you could find the length
of (the rows collection works as an array).

Example:
<table id="tableId">
<tr><td>Row 1</td></tr>
<tr><td>Row 2</td></tr>
<tr><td>Row 3</td></tr>
</table>
<form><input type="button" value="Count Table Rows"
onclick="alert( document.getEle mentById('table Id').rows.lengt h);"></form>

Note that it only counts the rows in the specified table - not also the
rows of the tables inside the table.

Works in IE5+ and NN6+.
Jul 23 '05 #3


Hi, thanks to ur reply! It's really a quick reply. thanks, thanks a lot
;)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #4
It's really a quick reply.
thanks a lot!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2481
by: Sandros | last post by:
Background: I'm collecting usability statistics for a group of applications. Each count has the following attributes: date, application, major heading, minor heading, count. My intent is to pull this back as XML and render it in to an HTML table. I have all this working and all the files are below. I would value any feedback. A simple example of the data looks like this:
1
1615
by: Hitit | last post by:
I found the script below in internet and I want it to create a page with links for each date changing according to date. For example: For August 10, the link in calendar page should point to: /cgi-bin/calendar_day.pl?userdir=calend&dept=boys&weekends=1&datestamp=20040 810 For August 11, the link in calendar page should point to: /cgi-bin/calendar_day.pl?userdir=calend&dept=boys&weekends=1&datestamp=20040 811
3
3837
by: Al Wilkerson | last post by:
Hey, I have a Web Form with a drop down list, textbox, and search button. When click the search button an SQL server database is queried fordata. Once I have the data in a dataset I use the dataset to dynamically create a Html Table control. I want to display the table on another frame page (target="main") without the web form controls (i.e. the textbox, search button, and dropdown list). I just want the table displayed only on the...
1
6351
by: Al Wilkerson | last post by:
Hey, I have a Web Form with a drop down list, textbox, and search button. When click the search button an SQL server database is queried fordata. Once I have the data in a dataset I use the dataset to dynamically create a Html Table control. I want to display the table on another frame page (target="main") without the web form controls (i.e. the textbox, search button, and dropdown list). I just want the table displayed only on the...
2
1695
by: PK | last post by:
Hi All, i got few questions to ask regarding about publishing dataset to html format !!! ------------------- PublishHTML("C:\Inetpub\wwwroot\Report.htm", myDataSet1.Tables("table01")) Quesion 1 - the above is the command to run the "PublishHTML" procedures... i want to know if the file path is dynamic change, and is changed according to the time when user install the application. if there is a way to change to something like...
5
1888
by: aljamala | last post by:
Hi, I have a group of 5 tables laid out of the web page. 2 go on the left side and 3 on the right. These tables retrieve data from the database so the number of records (rows) returned varies. So the problem I am having at the moment is that if the table gets longer by one or two rows, all my alignment goes of out whack for the other tables. Is there a way for example to place table #2 right after table#1 ends?
1
3417
by: gdarian216 | last post by:
I am writing a program that can take input from a user or file of positive and negative numbers. Then display them in a html table. The negative numbers have to be outputted in red html font on the table and the positive numbers will just be outputted. I wrote a loop that shouldn't terminate till a zero is entered. For some reason it won't print my table. This is what I have so far if anyone can shine some light on this for me I would be...
1
1497
by: gdarian216 | last post by:
I have written the program to take input and put it in a table with negative numbers in red and positive numbers in black. The last cell in the row is used for the sum of that row. My question now is how would I go about getting the code for the columns up and down and not just across if I don't know in advance how many inputs there are? This is what I have done so far. #include <iostream> using namespace std; int main() { cout <<...
12
5826
by: Steve | last post by:
I have been studying the Adjacency List Model as a means of achieving a folder structure in a project I am working on. Started with the excellent article by Gijs Van Tulder http://www.sitepoint.com/article/hierarchical-data-database My database has this basic structure: Id FolderName
8
5195
by: roop1 | last post by:
I am using a perl script to produce a six element array. When I click a string in the first element, I am linked to a html table (all.html) and the matching string is displayed in the first row of the html table. This is the variable I am using in the perl script: $ewstring= substr($string,3); and this is the link to the html table (all.html): $thisrow = $thisrow . "<td>" . $myfont . "<a...
0
9810
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10524
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10562
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7768
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5805
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4434
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3997
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3092
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.