my code is this:

<head>

<title>New Page 1</title>

<?php

echo"<SCRIPT LANGUAGE=\"JavaScript\">\n";
echo"<!-- \n";
echo"IMAGE01 = \"on.jpg\"\n";
echo"IMAGE02 = \"off.jpg\"\n";

echo"function imgover(imgname){\n";
echo"imgname.src = IMAGE01\n";
echo"}\n";
echo"function imgout(imgname){\n";
echo"imgname.src = IMAGE02\n";
echo"}\n";
echo"//-->\n";
echo"</SCRIPT>\n";
?>


</head>

Then in the body:

<?php echo"<IMG NAME=\"IMAGE01\" SRC=\"off.gif\" WIDTH=20 HEIGHT=15 BORDER=0><A HREF=\"index.php\" onMouseOver=\"imgover(IMAGE01)\" onMouseOut=\"imgout(IMAGE01)\"> Home</A><BR> \n"; ?> 

Could anyone please help to make this code work??

    Can someone please help me to make the onmouseover event work it is for my menu. Already spend hours of waiting for a reply.
    Is it not possible or something to do a mouseover in php?

      onmouseover is a Javascript function which runs on the client-side (in the browser). PHP is usually running on the web server and therefore can have no knowledge of where the user places the mouse.

      It may be that someone here can help, but I would suggest you try a Javascript forum. Or maybe to improve your chances here, you could run the script and then view the source code. Then if you paste the source code onto this message, it will be easier to find the problem.

      Good luck

        Plus.....all of your PHP code uses echo to output to the client.........why don't you just use HTML ?

          Thanks for the reply but my code is already listed above

            Originally posted by Rodders
            Plus.....all of your PHP code uses echo to output to the client.........why don't you just use HTML ?

            I dont use html because my page is in php and it is serverside so i think i got to parse it first??

              no, all code you post here is pure html/js. you do not neet php to do it.
              i do not run it, but if its not working then you got a js error. absolutely no relation with php.

              take a look at www.hotsripts.com
              i believe there is dozens of scripts doing what you are trying to do, whatever it is...

              good luck.

                Originally posted by icaro
                no, all code you post here is pure html/js. you do not neet php to do it.
                i do not run it, but if its not working then you got a js error. absolutely no relation with php.

                take a look at www.hotsripts.com
                i believe there is dozens of scripts doing what you are trying to do, whatever it is...

                good luck.

                Thanks
                When i use it as html in my php page it does not work I think it has got to do with the client side and serverside processing

                  besides

                  echo " " ;

                  nothing else in that code is php related 😉

                    phptrouble,

                    I really don't mean to sound condescending, and if it comes off that way, I apologize.

                    You really need to learn a little more about programming fundamentals and the difference between client-side scripting and server-side scripting.

                    You do not have to echo a single statement to get a php page to output HTML. Of course, you can't include straight HTML code inside php tags (<?php and ?>), but if you took a complete .html file, and renamed it with a .php extension, it would still work.

                    You do understand that at least, don't you?

                    As far as your code goes, you need to take it ALL out of the echo statements, and out of the <?php and ?> tags, and just type it in the same way you would do in an .html file.

                    Because this is not related in any way to PHP, you need to ask this question in a Javascript forum. There are many around, do a search on google.

                      but to save the time, here is the javascript code above with all the errors fixed.

                      <SCRIPT LANGUAGE="JavaScript">
                      <!--
                      var IMAGE01 = "on.jpg"
                      var IMAGE02 = "off.jpg"
                      
                      function imgover(imgID) {
                      	document.images.imgID.src = IMAGE01
                      }
                      
                      function imgout(imgID) {
                      	document.images.imgID.src = IMAGE02
                      }
                      
                      //-->
                      </SCRIPT>
                      
                      <!-- here is the html code test -->
                      
                      <img src="off.jpg" onmouseover="imgover('myImage'); return true" onmouseout="imgout('myImage'); return true" name="myImage">
                      

                      there were just a few probs w/ the variables and the actual image identifiers being set as well as the onmouseover and out portion of the img tag.

                        thank you 🙂
                        uh oh, i hope you meant me :eek:

                          Write a Reply...