Page 1 of 1

onMouseOver / onMouseOut event Javascript

Posted: Sun Jan 01, 2006 9:55 pm
by spitfire_esquive
hello guys, happy new year!

i just wanted to know how to include the onMouseOver event (Javascript) in this PHP script I made considering the fact that in the echo statement of PHP you have to enclose the succeeding statement with a double quotation (")

Code: Select all

echo "<td>";
how can I insert

Code: Select all

td align="center" bgcolor="#0000ff" onMouseOver="this.bgColor='#ff0000'" onMouseOut="this.bgColor='#0000ff'"
i am confused on how the quotes and double quotes work in this case.

sorry for the stupid question.

thanks!

Posted: Sun Jan 01, 2006 9:58 pm
by Chris Corbyn
Escape them using backslashes...

Code: Select all

echo "<td align=\"center\" bgcolor=\"#0000ff\" onMouseOver=\"this.bgColor='#ff0000'\" onMouseOut=\"this.bgColor='#0000ff'\">";
If a quote inside a string is the same as the quote that opened the string it must be preceded by a backslash :)

Posted: Sun Jan 01, 2006 9:59 pm
by spitfire_esquive
thank you very much! escapes!