Jump to content

Include file - linked to other file


bob_marely

Recommended Posts

 

I have this problem which I really don't know how to solve… it's really wired and I've tried so many ways then I thought that a different view might reveal something I didn't notice.

So…

I have six divs in my php page with display style = none, except the first div which is visible. I have buttons which their onclick event change the display of the divs, i.e. make one div visible and the others invisible. It works like magic except for the second div where it also includes the php file from the third div. 

Of course that snap code is always better than words:

<div id="1" style="width: 950px; display: block">

<?php include('file1.php'); ?>

</div>

 

<div id="2" style="width: 950px; display: none">

<?php include('file2.php'); ?>

</div>

 

<div id="3" style="width: 950px; display: none">

<?php include('file3.php'); ?>

</div> 

<div id="4" style="width: 950px; display: block">

<?php include('file4.php'); ?>

</div>

 

<div id="5" style="width: 950px; display: none">

<?php include('file5.php'); ?>

</div>

 

<div id="6" style="width: 950px; display: none">

<?php include('file6.php'); ?>

</div> 

 

 

And this is the code for the onclick event:

<a href="javascript:void(0);" onclick="includefile(1); return false;" > <img name="child" border="0" src="images/child.gif" width="180" height="30" /></a>

 

There are six buttons like this one with different gifs and each button include different file.

 

 

I tried many things – change the order, replace the included files, create new files, etc. but the bug still remains: always when changing the second div visibility it includes also the file in the div below it (I checked the display style of the third div and it remains none – it's just the third file is included under the second div).

 

Sorry for the long story – I wanted to be clear and I believe that knowing all the details may help for having some ideas.

 

Thank you for any advice!!

 

Link to comment
https://forums.phpfreaks.com/topic/189704-include-file-linked-to-other-file/
Share on other sites

Maybe it's a browser issue? Have you checked this in another browser to make sure that the browser is just not misinterpreting something from the css part. I think this is either a javascript or css issue with a browser.  I don't think there is any php issue here. This is a CSS issue with a browser or at least it sounds like it. Even if this repeats itself in multiple browsers I'd try wrapping you div in inside a wrapper div....

Try something in that manner...

<div id="WRAPPER" style="width:1050px">
<div id="1" style="width: 950px; display: block">
   <?php include('file1.php'); ?>
</div>
            
<div id="2" style="width: 950px; display: none">
   <?php include('file2.php'); ?>
</div>
                  
<div id="3" style="width: 950px; display: none">
   <?php include('file3.php'); ?>
</div> 
<div id="4" style="width: 950px; display: block">
   <?php include('file4.php'); ?>
</div>
            
<div id="5" style="width: 950px; display: none">
   <?php include('file5.php'); ?>
</div>
                  
<div id="6" style="width: 950px; display: none">
   <?php include('file6.php'); ?>
</div>  

</div> <!-- End of wrapper DIV -->

You say in your text that only the first div is visible initially, but you clearly have the div with id=4 also visible

 

2 things to remember, which you seem from your text to be unsure about.

 

1) all the include files will be included when the file runs on the server before the page is transmitted.

2) the visibility change will just change the visibility, not the inclusion of the php files.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.