Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

style.display problem when traversing the DOM 1

Status
Not open for further replies.

rvandenb

Programmer
Oct 5, 2004
3
NL
For my print script I need to expand some tables which are not visible (style.display = 'none'). When I go through my site using this script:

var allTables = document.body.getElementsByTagName("TABLE");
for (i=0; i < allTables.length; i++) {
if (allTables.style.display == 'none') {
allTables.style.display='';
}
}

the tables don't show up...
Even when I use TR instead of TABLE in this script they won't show.
An example of the page I'm working on can be found here:

This example shows 1 table, but in reallity it can be 10 tables. So I cannot use their ID.

Can anyone give me a hint on how to show these tables?
Dynamicaly adding a stylesheet won't work either (CSS media)...

RB
 
There are many reasons. The first two that came to mind are:

[ol][li]You're surrounding <tr> tags with <div> tags. This is not good form. There should be nothing separating a <table> tag from a <tr> tag.[/li]

[li]Your <tr> and <table> tags themselves do not have any display style associated with them. Rather, you're surrounding them with <div> tags (see #1) and then setting the style of the <div> tags. Either a) remove the <div> tags and set the style of the <table> or <tr> tags, or b) continue using the <div> tags (wrong) and get the elements by tag using "div" not "table"[/li][/ol]

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Thnx for your help.
Option 2 would be the best :)
I already wondered why the w3c validator complained about those TR's being between the DIV.

When removing the DIV's and traversing my site using the TBODY element everything goes fine.

RB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top