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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Div tags: position and visibility

Status
Not open for further replies.

dwhalen

Programmer
Feb 22, 2002
105
CA
Does anybody know how to help me?

I am writing a perl function to print out reports and make them look nice and neat. I divide up the report into div tags (pages) and hide all of them except the first one. I then have a next and previous button that allows the user to navigate through the pages hiding and showing each page. I want to keep the flow of the page based on the visible div, so I set the div to relative and then make it visible. Also, I don't want the other div tags affecting the flow of the html page so I set them to absolute and then hide them.

This works fine in the latest version of Netscape but in the latest IE the flow of the document is perfect but the divs are not becoming visible when I set them to visible. Can anyone tell me why?

#This is a simplified demo of what I have

<style>
.reportPage{
position:absolute;
visibility:hidden;
margin-left:25%;}
</style>

and this is how I have the html page set up

<table>
<!--Top of page -->

</table>

<div id=&quot;page1&quot; class=&quot;reportPage&quot;>
<table>
<!--Results go here-->
</table>
</div>

<div id=&quot;page2&quot; class=&quot;reportPage&quot;>
<table>
<!--Results go here-->
</table>
</div>

etc...

<table>
Bottom of page

</table>


this is my javascript:

onload=&quot;
livePage = document.getElementById('page1');
livePage.style.position='relative';
livePage.style.visibility='visible';
&quot;

function nextPage (){

livePage.style.position='absolute';
livePage.style.visibility = 'hidden';

reportPage++;

livePage =document.getElementById('page'+reportPage);
livePage.style.position='relative';
livePage.style.visibility = 'visible';
document.report.whatPage.value='Page '+reportPage+ ' of ' +totalPages;


}


Any help?

Thanks
 
Try replacing your &quot;nextPage()&quot; function with the following code. Also add the browser identifications. The problem may be with the getElementById method that isn't standard on IE like it is on NS 7 and Moz.
Code:
var DOM = (document.getElementById)? true:false;
var NS4 = (document.layers)? true:false;
var IE4 = (document.all)? true:false;

function nextPage() {
  var targetId = 'page'+reportPage;
    if (NS4) {
      document.layers[targetId].visibility = &quot;hide&quot;;
    } else if (DOM) {
      document.getElementById(targetId).style.visibility = &quot;hidden&quot;;
    } else {
      document.all[targetId].style.visibility = &quot;hidden&quot;;
    }
  reportPage++;
    if (NS4) {
      document.layers[targetId].visibility = &quot;show&quot;;
    } else if (DOM) {
      document.getElementById(targetId).style.visibility = &quot;visible&quot;;
    } else {
      document.all[targetId].style.visibility = &quot;visible&quot;;
    }
}
Einstein47
(&quot;For every expert, there is an equal and opposite expert.&quot; - Arthur C. Clarke)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top