Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP + javascript mouse over gallery help
Old 08-09-2008, 06:02 AM PHP + javascript mouse over gallery help
Junior Talker

Posts: 1
Trades: 0
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>

######################################
ashadweb is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-09-2008, 08:24 AM Re: PHP + javascript mouse over gallery help
bas
Super Talker

Posts: 108
Name: Bas
Trades: 0
Well, it's quit logical your code doesn't work!
The main issue is in your (X)HTML: wrong use of quotation marks for attributes.

This should work a bit better:
Code:
<p>
<?= '<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>
What I changed:
  • single quotes for PHP, double quotes in (x)HTML (much more clear)
  • ALL (x)HTML attributes begin and end with a quotation mark now
  • The array-variables are placed outside the PHP strings
  • Maybe not required in HTML, but ending slash in img-elements
bas is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP + javascript mouse over gallery help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10085 seconds with 12 queries