tehdobe Posted June 16, 2006 Share Posted June 16, 2006 Hello,I am kinda of new to php, here is what I want. I have 4 links each of them have a mouseOn and mouseOff image. However; what I want the links to do is when I go to one of the 4 pages I want the mouseOn to stay on till I goto one of the other 3 links. If that makes any sense. I am trying to do this with a if else statement for each link. I have all 4 links in a header.php document and the javascript in a different document. Both of which are being included in a index.php. I think most of my problem with it not working is arising from the header.php the code is as follows:<? if($_SERVER['PHP_SELF'] == "\/index.php") { ?> <td width="101"><A HREF="<?=$www_url;?>/index.php"><img src="<?=$www_url;?>/images/links/homebuttonON.jpg" width="101" height="31" border="0"></a></td> <? } else { ?> <td width="101"><A HREF="<?=$www_url;?>/index.php" onMouseover="imageOn('home')" onMouseout="imageOff('home')"><img name="home" src="<?=$www_url;?>/images/links/homebutton.jpg" width="101" height="31" border="0"></a></td> <? } ?> <? if($_SERVER['PHP_SELF'] == "\/content.php") { ?> <td width="101"><A HREF="<?=$www_url;?>/content.php"><img src="<?=$www_url;?>/images/links/contentbuttonON.jpg" width="101" height="31" border="0"></a></td> <? } else { ?> <td width="101"><A HREF="<?=$www_url;?>/content.php" onMouseover="imageOn('content')" onMouseout="imageOff('content')"><img name="content" src="<?=$www_url;?>/images/links/contentbutton.jpg" width="101" height="31" border="0"></a></td> <? } ?> <? if($_SERVER['PHP_SELF'] == "\/aboutus.php") { ?> <td width="101"><A HREF="<?=$www_url;?>/aboutus.php"><img src="<?=$www_url;?>/images/links/aboutusbuttonON.jpg" width="101" height="31" border="0"></a></td> <? } else { ?> <td width="101"><A HREF="<?=$www_url;?>/aboutus.php" onMouseover="imageOn('aboutus')" onMouseout="imageOff('aboutus')"><img name="aboutus" src="<?=$www_url;?>/images/links/aboutusbutton.jpg" width="101" height="31" border="0"></a></td> <? } ?> <? if($_SERVER['PHP_SELF'] == "\/support.php") { ?> <td width="101"><A HREF="<?=$www_url;?>/support.php"><img src="<?=$www_url;?>/images/links/supportbuttonON.jpg" width="101" height="31" border="0"></a></td> <? } else { ?> <td width="101"><A HREF="<?=$www_url;?>/support.php" onMouseover="imageOn('support')" onMouseout="imageOff('support')"><img name="support" src="<?=$www_url;?>/images/links/supportbutton.jpg" width="101" height="31" border="0"></a></td> <? } ?>All it is allowing me to do right now is use the mouseOn mouseOff. It won't stick to the mouseOn when I click the link using this code. Any ideas suggestions? resolution :D?-dobe Quote Link to comment https://forums.phpfreaks.com/topic/12122-if-else-help/ Share on other sites More sharing options...
trq Posted June 16, 2006 Share Posted June 16, 2006 This whole question seems to be more javascript then php. You do know that mouseOn is active ONLY when the mouse is ON it?Anyway... your question would be best suited to the javscript forum no need for php to be involved at all here. Quote Link to comment https://forums.phpfreaks.com/topic/12122-if-else-help/#findComment-46156 Share on other sites More sharing options...
tehdobe Posted June 16, 2006 Author Share Posted June 16, 2006 [!--quoteo(post=384444:date=Jun 15 2006, 09:55 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 15 2006, 09:55 PM) [snapback]384444[/snapback][/div][div class=\'quotemain\'][!--quotec--]This whole question seems to be more javascript then php. You do know that mouseOn is active ONLY when the mouse is ON it?Anyway... your question would be best suited to the javscript forum no need for php to be involved at all here.[/quote]I understand that mouseOn is Only active when the mouse is on it; however, the code I wrote should allow it to work due to the fact. I have an if else statement, and the if has no java in it. and then its suppose to call the javascript when else or w/e if I make any sense. The code I wrote should be working regardless of the javascript or not. when the page loads the If statement is not functioning only the else statement is. Quote Link to comment https://forums.phpfreaks.com/topic/12122-if-else-help/#findComment-46315 Share on other sites More sharing options...
kanikilu Posted June 16, 2006 Share Posted June 16, 2006 This probably doesn't have anything to do with your problem, but why are you escaping forward slashes?[code]if($_SERVER['PHP_SELF'] == "\/index.php")[/code]Shouldn't that simply be:[code]if($_SERVER['PHP_SELF'] == "/index.php")[/code]? Quote Link to comment https://forums.phpfreaks.com/topic/12122-if-else-help/#findComment-46321 Share on other sites More sharing options...
tehdobe Posted June 16, 2006 Author Share Posted June 16, 2006 [!--quoteo(post=384620:date=Jun 16 2006, 10:59 AM:name=kanikilu)--][div class=\'quotetop\']QUOTE(kanikilu @ Jun 16 2006, 10:59 AM) [snapback]384620[/snapback][/div][div class=\'quotemain\'][!--quotec--]This probably doesn't have anything to do with your problem, but why are you escaping forward slashes?[code]if($_SERVER['PHP_SELF'] == "\/index.php")[/code]Shouldn't that simply be:[code]if($_SERVER['PHP_SELF'] == "/index.php")[/code]?[/quote]I wish I knew the code I started out using was[code]if($PHP_SELF == "\/index.php")[/code] I don't know if its wrong or right it doesn't seem to make it work or not work adding or removing the escaping forward slash. So I guess it can't be to big of a deal but I dunno like I said I am kinda new :/[!--quoteo(post=384620:date=Jun 16 2006, 10:59 AM:name=kanikilu)--][div class=\'quotetop\']QUOTE(kanikilu @ Jun 16 2006, 10:59 AM) [snapback]384620[/snapback][/div][div class=\'quotemain\'][!--quotec--]This probably doesn't have anything to do with your problem, but why are you escaping forward slashes?[code]if($_SERVER['PHP_SELF'] == "\/index.php")[/code]Shouldn't that simply be:[code]if($_SERVER['PHP_SELF'] == "/index.php")[/code]?[/quote]Nevermind!!! Kanikilu your a the master I guess I am just dumb thanks for helping me that worked. Quote Link to comment https://forums.phpfreaks.com/topic/12122-if-else-help/#findComment-46324 Share on other sites More sharing options...
kanikilu Posted June 16, 2006 Share Posted June 16, 2006 How is your site setup in terms of directory structure? Perhaps try using the absolute path. If your [i]if[/i] statements always seem to fail, you could also try to just echo out $_SERVER['PHP_SELF'] somewhere outside your if's just to see what you are getting...--EDIT--Nevermind, then, glad that worked, I was running out of ideas ;-) Quote Link to comment https://forums.phpfreaks.com/topic/12122-if-else-help/#findComment-46333 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.