Jump to content


Photo

if. else help


  • Please log in to reply
5 replies to this topic

#1 tehdobe

tehdobe
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 16 June 2006 - 02:48 AM

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

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 16 June 2006 - 02:55 AM

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.

#3 tehdobe

tehdobe
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 16 June 2006 - 03:50 PM

[!--quoteo(post=384444:date=Jun 15 2006, 09:55 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 15 2006, 09:55 PM) View Post[/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.

#4 kanikilu

kanikilu
  • Members
  • PipPip
  • Member
  • 29 posts
  • LocationDallas, TX

Posted 16 June 2006 - 03:59 PM

This probably doesn't have anything to do with your problem, but why are you escaping forward slashes?
if($_SERVER['PHP_SELF'] == "\/index.php")
Shouldn't that simply be:
if($_SERVER['PHP_SELF'] == "/index.php")
?

#5 tehdobe

tehdobe
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 16 June 2006 - 04:10 PM

[!--quoteo(post=384620:date=Jun 16 2006, 10:59 AM:name=kanikilu)--][div class=\'quotetop\']QUOTE(kanikilu @ Jun 16 2006, 10:59 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
This probably doesn't have anything to do with your problem, but why are you escaping forward slashes?
if($_SERVER['PHP_SELF'] == "\/index.php")
Shouldn't that simply be:
if($_SERVER['PHP_SELF'] == "/index.php")
?
[/quote]

I wish I knew the code I started out using was
if($PHP_SELF == "\/index.php")

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) View Post[/div][div class=\'quotemain\'][!--quotec--]
This probably doesn't have anything to do with your problem, but why are you escaping forward slashes?
if($_SERVER['PHP_SELF'] == "\/index.php")
Shouldn't that simply be:
if($_SERVER['PHP_SELF'] == "/index.php")
?
[/quote]

Nevermind!!! Kanikilu your a the master I guess I am just dumb thanks for helping me that worked.

#6 kanikilu

kanikilu
  • Members
  • PipPip
  • Member
  • 29 posts
  • LocationDallas, TX

Posted 16 June 2006 - 04:14 PM

How is your site setup in terms of directory structure? Perhaps try using the absolute path. If your if 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 ;-)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users