PDA

View Full Version : php in js - rollover path



cmplx
January 5th, 2005, 10:00 AM
i'm trying to make a site that has rollovers coded in javascript, but want to be able to have the path for the images stored in a variable ($images_path) so i can modify according to different folders/levels i'm in.
i've been running into several parse errors.

here's what i tried with escape characters (lines 2-10 each onmouseover/down is its own line):

<?php
include
"<a href=\"$pages_path/index.php\"
onmouseover=\"changeImages('about', '$images_path/about_over.gif'); return true;\"
onmouseout=\"changeImages('about', '$images_path/about.gif'); return true;\"
onmousedown=\"changeImages('about', '$images_path/about_over.gif'); return true;\"
onmouseup=\"changeImages('about', '$images_path/about_over.gif'); return true;\">
<img name=\"about\" src=\"$images_path/about.gif\" width="78" height="22" border="0" alt=""></a>"
?>

however, i get a parse error:

Parse error: parse error, unexpected T_LNUMBER in /home2/whatthe/public_html/work/sunfood/pages/menu.php on line 9

line 9 is the <img> tag. not too sure what is causing this or if this is even or if this can even work with php inside a javascript.
anyone have any idea if this will work or if there's another work around to for this? thanks.

senocular
January 5th, 2005, 10:07 AM
whats thte include for? I think you need to get rid of that and work off of html with php scattered about within instead of the whole thing being written out in php. So do that, then where you need the path just use

<?= $images_path; ?>

cmplx
January 5th, 2005, 10:49 AM
whats thte include for? I think you need to get rid of that and work off of html with php scattered about within instead of the whole thing being written out in php. So do that, then where you need the path just use

<?= $images_path; ?>


so it would look something like this then:

'<?= $images_path; ?>/about_over.gif' ?

cmplx
January 5th, 2005, 11:02 AM
thanks senocular!! that works perfectly now :tie:

i was trying what you had but didn't exactly know it.