PHP and javascript

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
BuzzT
Forum Newbie
Posts: 6
Joined: Thu Jun 13, 2002 9:44 am

PHP and javascript

Post 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>";
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

Try

onMouseOver='javascript:displayStatusMsg($msgs)'...
Bennettman
Forum Contributor
Posts: 130
Joined: Sat Jun 15, 2002 3:58 pm

Post 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.
User avatar
amnuts
Forum Newbie
Posts: 16
Joined: Fri Jun 14, 2002 1:48 pm
Contact:

Re: PHP and javascript

Post 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
Post Reply