PDA

View Full Version : Can't get Javascript to work in PHP


DredNot
05-15-2003, 01:59 AM
How can I add an 'OnMouseOver' in a link to display a message in the status bar (to hide the URL!)?

When I try this:
echo "<b>Your email has been sent.</b><br /><A HREF=http://hop.clickbank.net/?nickname1/nickname2
onMouseOver=" window.status='Buy This!'; return true"
onMouseOut="window.status=' '; return true" TARGET=_top>Buy This!</A><br />";
I get this:
parse error, unexpected T_STRING... etc.

I'm very much a PHP newbie and would appreciate any help.

DredNot

Mhtml
05-15-2003, 02:42 AM
Well, the syntax highlighting was a dead give away but I guess you didn't notice.

You string is encased in double quotes "string" and inside your string you have double quotes for the html attributes, "<tag string="yes">"..

Now my point, you need to escape the quotes using the escape character \. so \" will escape the " and \\ will escape the escape character leaving you with \.

echo "<b>Your email has been sent.</b><br /><a href=\"http://hop.clickbank.net/?nickname1/nickname2
onMouseOver=\" window.status='Buy This!'; return true\"
onMouseOut=\"window.status=' '; return true\" target=\"_top\">Buy This!</a><br />";


Also I noticed that you are going partly xhtml in that code, but you have attributes in uppercase. They are supposed to be in lower case, I changed that for you as you can see.

DredNot
05-15-2003, 02:53 AM
I new it had to be something simple! Thanks a lot, much appreciated :thumbsup:

DredNot

Mhtml
05-15-2003, 06:17 AM
No problem! :)