Click to See Complete Forum and Search --> : PHP + javascript mouse over gallery help


ashadweb
08-09-2008, 06:57 AM
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>

######################################

NogDog
08-09-2008, 09:05 AM
For one thing, you onmouseover values need to be quoted, e.g.:

<?= "<span onmouseover='document.rollimg.src=image0.src;'>
<img src=\"../cars_images/$im_array[0]\" class='thumb_img' width='150' height='150' alt='1'>
</span> " ?>

PS: for forward compatibility, you really should avoid the short tags ("<?" and "<?=") and instead use the long versions ("<?php" and "<?php echo").