Page 1 of 1

PHP and javascript

Posted: Mon Jun 17, 2002 4:08 pm
by BuzzT
I am trying to hide a URL onMouseOver within PHP. I keep getting runtime errors. I have tried many things, but nothing works. All I want to do is hide my URL on mouseovers. The information is stored in a MySQL database.

Here's what it looks like

----the javascript-----
<script language="JavaScript">
function displayStatusMsg(msgStr) {
status=msgStr;
document.returnValue = true;
}
</script>

-----the variable------
$msgs=$row["name"];


-----the echo statement-----
echo "<a href='$link' onMouseOver='displayStatusMsg($msgs)';return document.returnValue>"."Click Here"."</a>";

Posted: Mon Jun 17, 2002 4:22 pm
by mikeq
Try

onMouseOver='javascript:displayStatusMsg($msgs)'...

Posted: Mon Jun 17, 2002 7:43 pm
by Bennettman
Use a normal link:

<a href="page.html" onMouseOver="window.status='text'; return true">

where text is what you want to appear in the status bar. If you just want it to appear blank, put this in:

<a href="page.html" onMouseOver="window.status=''; return true">

If that was in PHP, it would be a simple print/echo command.

Re: PHP and javascript

Posted: Tue Jun 18, 2002 8:30 am
by amnuts
BuzzT wrote: echo "<a href='$link' onMouseOver='displayStatusMsg($msgs)';return document.returnValue>"."Click Here"."</a>";
Don't forget that when you're echoing the variables it's going to print out whatever is in teh variable. So what sending the text as a parameter to the javascript you'll need to encase it in quotes, such as:

Code: Select all

echo "<a href="$link" onMouseOver="displayStatusMsg('$msgs'); return document.returnValue">Click Here</a>";
Andy