Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Table Data value

Status
Not open for further replies.

kevindmorgan

IS-IT--Management
Mar 1, 2004
4
US
Suppose I have a single web page with a single table on the page. Nothing else. Let's say the web page is at
The table has one row, and three columns. Inside each of the 3 cells of the table is a number.

How can I use Javascript to go out and "look" at those values and assign them to a variable, or perhaps, create an array with them.

I don't want to write the script IN the "myPage.htm" file...but rather "get" the info on that page from another page. I hope I explained this well enough, and thanks in advance for any help!
 
Is the page you want to get the data with on the same domain as the myPage.htm? If not, then you will have to look at a server-side solution (using something like PHP). If so, then you can look at opening the myPage.htm in an iframe (hosted by the page that you do want to write the script in). You would use dom methods like getElementsByTagName('TR') to get each row of the table and then walk the nodes. If you assign a classname to each TD, then it will be a little easier (you can use getElementsByTagName('TD') and then iterate through the collection testing the classname to determine if the cell contents are useful to you).

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top