Jump to content


Photo

javascript in php code


  • Please log in to reply
2 replies to this topic

#1 leon

leon
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 13 April 2006 - 08:42 PM

Hello, I was trying to insert rollover image script to php. But I dont think it will be easy. can you check this code please? How can it be adjusted?


<?php echo "<a href=\"$PHP_SELF?page=$pageNum&product_id={$data['id']}\" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image71','','{data['image_roll']}',1)">"; ?>

Image_roll is the field from the database.

#2 deadonarrival

deadonarrival
  • Members
  • PipPipPip
  • Advanced Member
  • 284 posts

Posted 13 April 2006 - 08:49 PM

Javascript is all run after your PHP is parsed, so basically just get PHP to echo exactly what you want to appear in the browser.

As long as your slashes and brackets dont overlap (for want of a better word appearing in my head right now) it will work fine.
DO {
$this->time_warp("Jump to the left","Step to the right","Bend knees in time");
} WHILE (2>1)

Warning: The above post may not make a lot of sense, and the sentence structure will suck. I tend to ramble a lot. Sorry ;-)

#3 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 13 April 2006 - 10:41 PM

you might be forgetting to escape your quotes. When using quotes within quotes, you need to put a backslash infront of the internal quote...

so, "\"" would equal "

I added backslashes to your code around the mouseover and mouseout -- should work fine now.


<?php echo "<a href=\"$PHP_SELF?page=$pageNum&product_id={$data['id']}\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image71','','{data['image_roll']}',1)\">"; ?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users