ashadweb Posted August 9, 2008 Share Posted August 9, 2008 Hi, I making a web site and i have a code but this is not working properly dont knw why help me code is bellow ############################################################## JAVA SCRIPT <script type="text/javascript"> if (document.images) { image0 = new Image; image1 = new Image; image2 = new Image; image0.src = "<?= $im_array[0] ?>"; image1.src = "<?= $im_array[1] ?>"; image2.src = "<?= $im_array[2] ?>"; } else { image0 = ''; image1 = ''; image2 = ''; document.rollimg = ''; } </script> ################################# PHP CODE <?= "<span onmouseover=document.rollimg.src=image0.src;> <img src=\"../cars_images/$im_array[0]\" class=thumb_img width=150 height=150 alt=1\"> </span> " ?> <?= "<span onmouseover=document.rollimg.src=image1.src;> <img src=\"../cars_images/$im_array[1]\" class=thumb_img width=150 height=150 alt=2\"> </span>" ?> <?= "<span onmouseover=document.rollimg.src=image2.src;> <img src=\"../cars_images/$im_array[2]\" class=thumb_img width=150 height=150 alt=3\"> </span>" ?> </p> <p align="center"> <?= "<img src=\"../cars_images/$im_array[0]\" class=thumb_img width=150 height=150 alt=Larger version of one of the smaller images above name=rollimg\">" ?> </p> ###################################### Link to comment https://forums.phpfreaks.com/topic/118903-solved-php-javascript-mouse-over-gallery-help/ Share on other sites More sharing options...
jacksonmj Posted August 9, 2008 Share Posted August 9, 2008 First replace "<?=" with "<?php echo" so that the PHP actually runs. Next add quotes around attribute values and onmouseover events, e.g. alt="Larger version of one of the smaller images above", onmouseover="document.rollimg.src=image0.src;" It is good practice to surround all attributes with quotation marks. Some, such as numbers, may not need them but most attributes will, so get into good habits. Then change name=rollimg to id="rollimg" and document.rollimg to document.getElementById("rollimg") . Referring to elements using document.name syntax will not work in most modern browsers. Then try your webpage again. And use the [ code ] tags on the forum when posting code. It's the "#" button just above the smilies. Link to comment https://forums.phpfreaks.com/topic/118903-solved-php-javascript-mouse-over-gallery-help/#findComment-612582 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.