Computing.Net > Forums > Web Development > reading a table

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

reading a table

Reply to Message Icon

Name: darkhalf
Date: October 5, 2005 at 13:44:31 Pacific
OS: xp
CPU/Ram: 512
Comment:

Hi,

Say I have 2 tables, which don't have any identifier. How could I get the innerHTML value of the first <td> in the first <tr> of the second table? I'm tottaly lost in the document.all...

Thank you,




Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: October 5, 2005 at 15:32:15 Pacific
Reply:

You should use IDs within the tables, table-rows, and table-cells as appropriate. For example, if you had the following two tables...

[table]
[tr]
[td id='1-1-1']Table 1 Row 1 Column 1[/td]
[td id='1-1-2']Table 1 Row 1 Column 2[/td]
[/tr]
[tr]
[td id='1-2-1']Table 1 Row 2 Column 1[/td]
[td id='1-2-2']Table 1 Row 2 Column 2[/td]
[/tr]
[/table]

[table]
[tr]
[td id='2-1-1']Table 2 Row 1 Column 1[/td]
[td id='2-1-2']Table 2 Row 1 Column 2[/td]
[/tr]
[tr]
[td id='2-2-1']Table 2 Row 2 Column 1[/td]
[td id='2-2-2']Table 2 Row 2 Column 2[/td]
[/tr]
[/table]

You could refrence the content of any cell using the id. For the first cell of table 1 you would use

document.getElementById('1-1-1').innerHTML

Michael J


0

Response Number 2
Name: Michael J (by mjdamato)
Date: October 5, 2005 at 15:34:48 Pacific
Reply:

You should also take a look at this page: http://www.metalusions.com/backstage/articles/8/


Michael J


0

Response Number 3
Name: darkhalf
Date: October 5, 2005 at 20:18:33 Pacific
Reply:

problem is, I don't control the content of the page.. I'm trying to read the content, and paste it in Excel...


0

Response Number 4
Name: Michael J (by mjdamato)
Date: October 5, 2005 at 21:49:44 Pacific
Reply:

How are you attempting to "read" the page? Screen scraper?


0

Response Number 5
Name: darkhalf
Date: October 6, 2005 at 04:36:10 Pacific
Reply:

I'm thinking of just iterating through the page using:
for (i=0;i<frm.document.all.length;i++)
if (frm.document.all(i).tagName == "TABLE")

Once I have the table I want... I guess I was thinking of useing cells/row to get the info in question.. but I don't knw how to phrase it.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon

Blocking a user Pop-Up Ads



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: reading a table

Read a file per month www.computing.net/answers/webdevel/read-a-file-per-month/2327.html

CSS within a table www.computing.net/answers/webdevel/css-within-a-table/1568.html

Split a table in Dreamweaver MX www.computing.net/answers/webdevel/split-a-table-in-dreamweaver-mx/1130.html