in php onmouseout is not working

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
pavanesh2009
Forum Commoner
Posts: 30
Joined: Wed Jan 13, 2010 7:24 am

in php onmouseout is not working

Post by pavanesh2009 »

Hi All!!

I am using onmouseover functionality in php & my code is here:
echo "<a href='#' onmouseover='gettree_nickname($var)'; onmouseout='setTimeout(gettree_nickname($var),1000);'>lookup a tree</a>";
Though onmouseover works fine,but onmouseout is not working properly.
Is there any syntax mistake, or way of using it is not correct, please suggest.
Thanks in advance!!
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: in php onmouseout is not working

Post by requinix »

PHP doesn't know what JavaScript is. Problems with one have absolutely nothing to do with the other.

Looking at it, are you sure you have the right code for the mouseout? It's the same stuff as the mouseover.
pavanesh2009
Forum Commoner
Posts: 30
Joined: Wed Jan 13, 2010 7:24 am

Re: in php onmouseout is not working

Post by pavanesh2009 »

Thanks tasairis for help!!

but in JavaScript the syntax is

setTimeout("functionName()", 1000); // with quotes

I am just trying to use it, Is there any other procedure to do this..

Thanks once again!!
tasairis wrote:PHP doesn't know what JavaScript is. Problems with one have absolutely nothing to do with the other.

Looking at it, are you sure you have the right code for the mouseout? It's the same stuff as the mouseover.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: in php onmouseout is not working

Post by Eran »

You have a semi-colon outside of the quotes -

Code: Select all

onmouseover='gettree_nickname($var)';
you need to remove that
realnsleo
Forum Newbie
Posts: 15
Joined: Sat May 16, 2009 12:08 pm

Re: in php onmouseout is not working

Post by realnsleo »

Try this:

Code: Select all

echo '<a href="#" [color=#0000FF]onmouseover[/color]="gettree_nickname('.$var.');" [color=#0000FF]onmouseout[/color]="[color=#FF4000]setTimeout[/color](\'gettree_nickname('.$var.')\', 1000);">lookup a tree</a>';
however what in what i'm seeing you are performing the same function for the mouseover and mouseout event. It would be nice if you stated exactly what you wanted with both events.
pavanesh2009
Forum Commoner
Posts: 30
Joined: Wed Jan 13, 2010 7:24 am

Re: in php onmouseout is not working

Post by pavanesh2009 »

Thanks for reply realnsleo & pytrin!!

I tried both suggestions but still same problem, let me explain it more clearly, I have menu link called "lookup a tree" once mouse comes over, it display a dropdown which is coming through ajax function, now i want as soon as user removes mouse from that position, dropdown should be disable(hide).I am displaying it inside a <li> tag, here is the code:

<?php
if( $_SESSION['user_id'] )
{
$sql = mysql_query("SELECT user_tree_id FROM user_tree_table WHERE user_id='$_SESSION[user_id]'");
while($row = mysql_fetch_array($sql))
{
$var = $row['user_tree_id'];
}
}
echo "<li>";
echo "<a href='#' onmouseover='gettree_nickname($var)'; onmouseout='setTimeout('gettree_nickname($var)',1000)';>lookup a tree</a>";
echo "<div id='tree_nicknamediv'></div>";
echo"</li>";
?>

Thanks in Advance!!

realnsleo wrote:Try this:

Code: Select all

echo '<a href="#" [color=#0000FF]onmouseover[/color]="gettree_nickname('.$var.');" [color=#0000FF]onmouseout[/color]="[color=#FF4000]setTimeout[/color](\'gettree_nickname('.$var.')\', 1000);">lookup a tree</a>';
however what in what i'm seeing you are performing the same function for the mouseover and mouseout event. It would be nice if you stated exactly what you wanted with both events.
jraede
Forum Contributor
Posts: 254
Joined: Tue Feb 16, 2010 5:39 pm

Re: in php onmouseout is not working

Post by jraede »

Put an alert in your javascript functions to check if they're being called at all, and maybe just aren't working.
pavanesh2009
Forum Commoner
Posts: 30
Joined: Wed Jan 13, 2010 7:24 am

Re: in php onmouseout is not working

Post by pavanesh2009 »

Thanks jraede!!

Well I checked alert & guess what ...It's working fine but when it comes to setTimeout, It's not working,I just want to call a function for a small time period & then it should go off.

Do I need to write a separate function for hiding this drop down?
jraede wrote:Put an alert in your javascript functions to check if they're being called at all, and maybe just aren't working.
jraede
Forum Contributor
Posts: 254
Joined: Tue Feb 16, 2010 5:39 pm

Re: in php onmouseout is not working

Post by jraede »

Well, if the alert isn't showing up, that means your function has an error (javascript unfortunately does not have error reporting through the browser). You'll need to post the non-working function if you want some help.

(Also, sorry for the delay, I forgot to request e-mail reply notifications so I just noticed this was still unsolved)
Post Reply