Forum Moderators: coopster

Message Too Old, No Replies

insert php variable inside javascript

         

stevebrett

6:04 pm on Jan 12, 2009 (gmt 0)

10+ Year Member



Im trying to get the variable $i to resolve inside the mouseover part of the javascript but can seem to get it right

Ive tried it with quotes and with escaped quotes, and even single quotes, but cant seem to get it right.

Could someone give me a double check

<?php $thumb= "<a href=\"properties/files/$i\" onmouseover=\"MM_swapImage('theImage','','properties/files/<?php echo $i; ?>',1)\" onmouseout=\"MM_swapImgRestore()\"><img src=\"../properties/files/th_$i\"></a>" ?>

thanks

Steve

trillianjedi

6:23 pm on Jan 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You're missing a semi-colon after the last double-quote. And you don't need the second <?php enclosure.

$thumb= "<a href=\"properties/files/$i\" onmouseover=\"MM_swapImage('theImage','','properties/files/$i',1)\"
onmouseout=\"MM_swapImgRestore()\"><img src=\"../properties/files/th_$i\"></a>";

PHP automatically parses all $variables inside double-quotes.

stevebrett

8:13 pm on Jan 12, 2009 (gmt 0)

10+ Year Member



thanks, that's what I thought and how I first had it, though now its parsing ok, the images arentt swapping. Im going to rest my eyes and look at it again tomorrow