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!!
Include file - linked to other file
Moderator: General Moderators
-
bob_marely
- Forum Newbie
- Posts: 5
- Joined: Mon Jan 25, 2010 2:46 am
-
amargharat
- Forum Commoner
- Posts: 82
- Joined: Wed Sep 16, 2009 2:43 am
- Location: Mumbai, India
- Contact:
Re: Include file - linked to other file
use following javascript code
Code: Select all
function includefile(id)
{
//hide all divs
for(i=1;i<=6;i++)
{
document.getElementById(i).style.display='none';
}
//display div with requetsed id
document.getElementById(id).style.display='block';
}-
bob_marely
- Forum Newbie
- Posts: 5
- Joined: Mon Jan 25, 2010 2:46 am
Re: Include file - linked to other file
Thanks! but I use a similar code:
As I mentioned it works good for all divs - except from div id=2 where it includes also the file which is included under div id =3...
My question is if anyone has an idea why it happens????
Code: Select all
function includefile(fname) {
for (i=1;i<=11;i++) {
if ( fname == i) {
document.getElementById(fname).style.display='block';
}
else {
document.getElementById(i).style.display='none';
}
}
}My question is if anyone has an idea why it happens????
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Include file - linked to other file
Either file2.php is actually including file3.php, or file2.php has some HTML that is breaking the HTML in the main page and so causing both divs to be displayed. You need to check file2.php and the view source of the resultant main page.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
bob_marely
- Forum Newbie
- Posts: 5
- Joined: Mon Jan 25, 2010 2:46 am
Re: Include file - linked to other file
Brilliant!
I used the w3 validator and indeed there was some missing tag...
Thanks alot!
I used the w3 validator and indeed there was some missing tag...
Thanks alot!