Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more - View Single Post - Inline PHP in HTML
View Single Post
Old 12-31-2009, 09:44 PM   #1 (permalink)
enden
Junior Member
 
Join Date: Dec 2009
Posts: 2
Default Inline PHP in HTML

Hi,
I'm new here and to PHP, just trying to get some good PHP knowledge. It'd be nice if I could receive any sort of help.

I am having trouble making a code piece work:

PHP Code:
<?php
function onMouseOver()
{
    echo 
"<script type='text/javascript'>window.alert('Mouseover called')</script>";
}
?>

<a href='blahblah.php' onmouseover='"<?php onMouseOver() ?>"'> <img name="item1" src="../aboutus.bmp" /></a>
In the code above, I'm simply trying to call the function onMouseOver(); using the onmouseover property from href. The problem is that the window.alert function is being called when I enter the page when it is supposed to call the window.alert function when I mouseover the image?

I even tried to put the whole code in php:
PHP Code:
<?php
function onMouseOver()
{
    echo 
"<script type='text/javascript'>window.alert('Mouseover called')</script>";
}
?>

<?php echo "<a href='blahblah.php' onmouseover='".onMouseOver()."' > <img name='item1' src=../aboutus.bmp' /></a>" ?>
Still doesn't work? For some reason!

Any ideas, anyone?!

Edit: Nevermind, I found a workaround.

Last edited by enden; 01-01-2010 at 01:06 AM. Reason: Figured it out
enden is offline   Reply With Quote
Sponsored Links