Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need to get <TD> value without a ID in the tag.

Posted on 2008-10-16
4
Medium Priority
?
2,130 Views
Last Modified: 2012-05-05
I have a <Table> with no ID and a <TD> with no ID and I have the following I need to be able to get the value from. I did not write the HTML nor can I change it, I'm using grease monkey on FF so I can make some changes to a website.

<td>157</td>
0
Comment
Question by:thaburner
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
flipz earned 2000 total points
ID: 22733954
You can use something like this:

var arrCells = document.getElementsByTagName('td');
for (idx=0;idx<arrCells.length;idx++) {
  strValue = arrCells[idx].innerHTML;
  alert(strValue);
}

The problem is this will give you the contents of every TD element on the page. You would need some identifiable property to distinguish which one you are looking for.
0
 
LVL 6

Expert Comment

by:tchamtieh
ID: 22733977
Use something like this in your jscript code.
var elTableCells = elTableRow.getElementsByTagName("td");
alert(elTableCells[0].innerText);

Open in new window

0
 

Author Comment

by:thaburner
ID: 22734035
flips I think that will do the trick because it will always be 11th in spot

if (idx==11){
   alert(strValue);
}

Thanks
0
 
LVL 11

Expert Comment

by:flipz
ID: 22734055
No problem - glad to help.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question