Jump to content

PHP image mouseover...


JustOneOldMan

Recommended Posts

Hi, new here.  Usually if I can't figure out how to do something on my own I just don't do it, but this I want to do.

 

I've placed a clickable button in the header of one of my SMF forums just above the standard menu bar.  No problem, but I want it to have mouseover capabilities.  I know I can place functions in the head section and use them to do it, but I'd really like to find a direct replacement for the one liner HTML equivalent:

 

<a href="http://www.thegamecommunity.com/forums/index.php?action=forum"

    onmouseover="document.NAME.src='http://www.thegamecommunity.com/myimages/storebutton2.gif'"

    onmouseout ="document.NAME.src='http://www.thegamecommunity.com/myimages/storebutton.gif'">

    <img name=NAME src='http://www.thegamecommunity.com/myimages/storebutton.gif'>

</a>

 

This of course gives a T_STRING error in PHP because of the quotes.  Does anyone know if this can be done in one line in PHP?  Appreciate any help, been driving me nuts for two days.  Thanks...

Link to comment
Share on other sites

leave it out of the php

 

<?php
stuff

?>
http://www.thegamecommunity.com/myimages/storebutton2.gif'"
    onmouseout ="document.NAME.src='http://www.thegamecommunity.com/myimages/storebutton.gif']
    <img name=NAME src='http://www.thegamecommunity.com/myimages/storebutton.gif'>
<?php
more stuff


?>

Link to comment
Share on other sites

leave it out of the php

 

Thanks resago, but I'm not really good enough at PHP to have it show where I want it without it being in a certain place in the PHP code, and I can't put an HTML section right there.  In other words, I'm just good enough to find where in the code I need something to go (or change), but about that's it.  I'd have no idea how to place it in the correct position in the table outside that section of code.  So, I either have to find a replacement for the HTML one-liner or just leave it as a bland clickable.

Link to comment
Share on other sites

phpSensei,

 

First, I have to apologize to everyone for neglecting to put the code in a code block in my first post.  Got a little over zealous and didn't notice till just now.

 

This is actually the code I'm trying to duplicate or use in an HTML block.

 

  <a href="http://www.somesite.com/forums/index.php?action=forum"
        onmouseover="document.NAME.src='http://www.somesite.com/myimages/storebutton2.gif'"
        onmouseout ="document.NAME.src='http://www.somesite.com/myimages/storebutton.gif'">
  <img name=NAME src='http://www.somesite.com/myimages/storebutton2.gif'>
  </a>

 

Just tried your suggestion and still get a T_STRING error.  As in:

 

  
$html = <<<HTML
<a href="http://www.somesite.com/forums/index.php?action=forum"
   onmouseover="document.NAME.src='http://www.somesite.com/myimages/storebutton2.gif'"
   onmouseout ="document.NAME.src='http://www.somesite.com/myimages/storebutton.gif'">
<img name=NAME src='http://www.somesite.com/myimages/storebutton2.gif'>
HMTL;
</a>

 

Possibly I misunderstood your suggestion?

Link to comment
Share on other sites

Okay, it won't let me modify my post, but the

 

</a>

 

is actually above the HTML; line in the above post, I just misplaced it in the code block.  The HTML; is really the last line.

 

I noticed though that this forum is set so that I can't modify my first post and then it wouldn't let me modify this last post for corrections.

Link to comment
Share on other sites

Unfortunately not.  I still get a T_STRING error at the "onmouseover" line...

 

$HTML = <<<HTML
<a href="http://www.somesite.com/forums/index.php?action=forum"
  onmouseover="document.NAME.src='http://www.somesite.com/myimages/storebutton2.gif'"399:
  onmouseout ="document.NAME.src='http://www.somesite.com/myimages/storebutton.gif'">
  <img name=NAME src='http://www.somesite.com/myimages/storebutton2.gif'>
</a>
HMTL;

 

Might just be a lost cause...

Link to comment
Share on other sites

::)

 

Sorry, I've been up for about 42 hours working on various stuff on the site and I can see from this whole thread I should just lay down.  Fingers still work, brain doesn't.

 

Fixed the HTML, but still get the T_STRING in the same place.  The code insertion is in the "index.template.php" file just under the random news section.  The button is working okay, guess I'll just leave it.  Just thought the mouseover would be good, then it got to be a mission.  I appreciate the help and responses, though...

Link to comment
Share on other sites

Sorry, had to go back and put the code back in to get the error.  Her ya go...

 

 

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in .../Themes/default/index.template.php on line 400

397: 
398: $HTML = <<<HTML
399:   <a href="http://www.somesite.com/forums/index.php?action=forum"
400:         onmouseover="document.NAME.src='http://www.somesite.com/myimages/storebutton2.gif'"
401:         onmouseout ="document.NAME.src='http://www.somesite.com/myimages/storebutton.gif'">
402:   <img name=NAME src='http://www.somesite.com/myimages/storebutton.gif'>
403:   </a>
404: HMTL;

Link to comment
Share on other sites

I already told you, change HMTL

 

use

 

$HTML = <<<HTML
<a href="http://www.somesite.com/forums/index.php?action=forum"
  onmouseover="document.NAME.src='http://www.somesite.com/myimages/storebutton2.gif'"399:
  onmouseout ="document.NAME.src='http://www.somesite.com/myimages/storebutton.gif'">
  <img name=NAME src='http://www.somesite.com/myimages/storebutton2.gif'>
</a>
HTML;

Link to comment
Share on other sites

Get exactly the same thing with $string.  I just put it back the way it was, you can look at it to see what I was trying to do, anyway.  It's the small store buttons just above the SMF menu.  The store isn't open yet (or the rest of the site), so I just have the link returning to the forum board.  It isn't worth all the trouble for a mouseover, though.  I really do appreciate the time spent trying to help, but I just thought maybe there was a PHP version of the inline HTML mouseover.

 

Think I'm going to get a little sleep and forget about it for a while.  If you think of anything else I'd still like to be able to do it.  Thanks again...

Link to comment
Share on other sites

Hi Northern,

 

I'd thought about that too, and I could also use a small Java script or put a couple of PHP functions in the HEAD.  I just thought that something this common and simple that could be done in one line in HTML should surely be able to be done in PHP in one line with no other code additions.

 

I searched the net till I went blind, looked through the half dozen PHP books I have, and just can't find anything.  Thought before I gave up I'd check with the pros.  It just looks like it can't be done.  It's not just this one instance that I'd like to have used it for, I could see where it would be handy in a number of places where I go in and make my quick little mods.

 

I appreciate it, but if I can't do it in one line I'd rather just leave it alone.  I have the functionality I wanted, this is strictly for aesthetics...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.