Click to See Complete Forum and Search --> : Newbie Question: Using onMouseOver with Perl


Sheridan18
02-23-2007, 12:41 AM
Hey,

I'm trying to use Javascript, specifically onMouseOver, on a Perl CGI form, but I'm having problems. For example, when I use print ", another double quote will close that command, so I have to use a single quote. However, using onMouseOver, you have to have yet another set of quotes inside the command. <a href="../index.html" onMouseOver="document.home.src='../images/home2.gif'"><img src="../images/home1.gif" border="0" name="home"></a> is what I'm trying to plug into the CGI page. I changed all the double quotes to single quotes, but I don't know what to change the single quotes to if there is anything to change them to. How do I get around this?

Thanks for any help.

Nedals
02-23-2007, 07:45 PM
There are 2 ways to solve the problem...

print '<a href="../index.html" onMouseOver="document.home.src= \'../images/home2.gif\'">';

escape the single quote using \'

OR

print qq{<a href="../index.html" onMouseOver="document.home.src= '../images/home2.gif'">};

use the qq{...}; method