Solved

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

Posted on 2008-10-16
4
2,120 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 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
No problem - glad to help.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now