Combining php and javascript

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jensl1972
Forum Newbie
Posts: 1
Joined: Sun Nov 02, 2003 2:42 pm

Combining php and javascript

Post by jensl1972 »

Hi all,

I'm trying to combine this php script:

<p><a href="<?php echo _URLFORLINK1; ?>" alt="<?php echo _ALTFORLINK1; ?>">
<?php $linky1 = _LINK1; if (file_exists($imgpath."1_link-".$language.".gif")) { $linky1 = "<img src=\"".$imgpath."1_link-".$language.".gif\" border=\"0\">"; } echo $linky1; ?></p>

with this javascript:

<a href="index.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image41','','<?php echo $imgpath; ?>2_link-dan.gif',1)"><img src="<?php echo $imgpath; ?>1_link-dan.gif" name="Image41" width="81" height="27" border="0" id="Image41"></a>

The first changes image according to selected language and the secon is a normal mouse over img swap from DreamWeaver.

Any suggestions?
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Echo the javascript+html and just add $variablename within the echo.

That usually works best.
Post Reply