Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Close "X" button on window popup in Firefox 7 37
initialise the object angular2 4 34
Angular - "nest" service calls? 18 23
Message not shown 5 33
When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

910 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

16 Experts available now in Live!

Get 1:1 Help Now