Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Cells in a table, document.getElementById('myTable').cells not working in ff
Old 08-21-2006, 04:23 AM Cells in a table, document.getElementById('myTable').cells not working in ff
bez
bez's Avatar
Skilled Talker

Posts: 53
Trades: 0
I need to check every cell in a table for its background image.

Ive tried using:

var x=document.getElementById('myTable').cells

To get an array with all the cells, this works in IE but firefox claims 'x has no value'.

??? ???

Is ff using a more updated version of JS? Is there another way to return all the cell elements as an array? Is this a bug in ff? All the support materials i can find tell me to access a table's cells as in the code above, so im a bit stuck now.

Cheers for feedback, good people.
bez is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-21-2006, 09:53 AM Re: Cells in a table, document.getElementById('myTable').cells not working in ff
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
You need to call it using the row:
Code:
document.getElementById("myTable").rows[0].cells
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 08-21-2006, 12:03 PM Re: Cells in a table, document.getElementById('myTable').cells not working in ff
Ultra Talker

Posts: 256
Location: Auckland, New Zealand
Trades: 0
There's probably an easier way to do this but my method is to store all cells together, instead of a row by row basis, that way you can check them all through another loop (your checking for background-image interests me, how do you plan on doing that?).

Code:
var tr = document.getElementById('myTable').rows;
var td = new Array()
for(i = 0, n = tr.length; i < n; i++) {
  for(j = 0, m = tr[i].cells.length; j < m; j++) {
    td.push(tr[i].cells[j]);
  }
}
Now all you would need to do is loop through the array, an example would be:

Code:
for(k = 0, p = td.length; k < p; k++) {
  alert(td[k].innerHTML);
}
This should grab all cells, even those that are in different table sections (thead,tfoot,tbody).

Cheers,

MC
__________________
#------------------------------signature---------------------------------------------------------------------------------#
Quote:
I am well recognised for what I don't do than what I do. Chores are just one of those things.
mastercomputers is offline
Reply With Quote
View Public Profile Visit mastercomputers's homepage!
 
Old 08-25-2006, 07:28 PM Re: Cells in a table, document.getElementById('myTable').cells not working in ff
kIDJOE's Avatar
Extreme Talker

Posts: 186
Location: Hollywood, CA
Trades: 0
or you can set the backgrounds with CSS and set ID's for each cell then you can pull the info you need by requesting ="alert(ID.style.backfroundImage)" you may need to getElementsById for FF
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

kIDJOE is offline
Reply With Quote
View Public Profile Visit kIDJOE's homepage!
 
Reply     « Reply to Cells in a table, document.getElementById('myTable').cells not working in ff
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19675 seconds with 12 queries