Page 1 of 1
in php onmouseout is not working
Posted: Thu Feb 18, 2010 4:14 am
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!!
Re: in php onmouseout is not working
Posted: Thu Feb 18, 2010 4:20 am
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.
Re: in php onmouseout is not working
Posted: Thu Feb 18, 2010 4:26 am
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.
Re: in php onmouseout is not working
Posted: Thu Feb 18, 2010 5:00 am
by Eran
You have a semi-colon outside of the quotes -
Code: Select all
onmouseover='gettree_nickname($var)';
you need to remove that
Re: in php onmouseout is not working
Posted: Thu Feb 18, 2010 5:02 am
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.
Re: in php onmouseout is not working
Posted: Thu Feb 18, 2010 8:09 am
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.
Re: in php onmouseout is not working
Posted: Thu Feb 18, 2010 11:04 am
by jraede
Put an alert in your javascript functions to check if they're being called at all, and maybe just aren't working.
Re: in php onmouseout is not working
Posted: Thu Feb 18, 2010 11:58 pm
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.
Re: in php onmouseout is not working
Posted: Fri Feb 26, 2010 3:38 pm
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)