Solved

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

Posted on 2008-10-16
4
2,123 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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 …
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

815 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

11 Experts available now in Live!

Get 1:1 Help Now