"I don’t know how I can execute an event of Javascript into a link in a program in Perl.
This event of JavaScript have executed a function that return a HTML page.
Anybody know how I can it?
Is it possible do it this?:
$datos=$datos.""<a href=’"" . $me . “”?C=OFERTAS2&EMPRESA="".$empresa_param.""&NREF="".$nref.""’ onMouseOver="“linkFTecnica(nref2)”">"";
Is the ‘linkFTecnica’ function in the javascript, or is it a perl function?
If it is a perl function, then you need
onMouseOver=" . linkFTecnica(nref2) . ">";
if it’s a javascript function, then the quotes around that are being seen by perl, and it thinks that linkFTecnica(nref2) is not part of the variable “$datos”
Do you get an error that looks something like this?
Bareword found where operator expected at test.pl line 1, near "'"" . $me . ""?C=OFERTAS2&EMPRESA="".$empresa_param.""&NREF="".$nref.""' onMouseOver"
(Missing operator before onMouseOver?)
Bareword found where operator expected at test.pl line 1, near """linkFTecnica"
(Missing operator before linkFTecnica?)
String found where operator expected at test.pl line 1, near ")"""
(Missing operator before ""?)
syntax error at test.pl line 1, near "'"" . $me . ""?C=OFERTAS2&EMPRESA="".$empresa_param.""&NREF="".$nref.""' onMouseOver"
This would be because you aren’t creating your string properly. If you’re trying to append a string to $dateos, you want your code to be like this
# assuming linkFTecnica is a perl function
$datos = $datos . "<a href='" . $me . "?C=OFERTAS2&EMPRESA=" . $empresa_param . "&NREF=" . $nref . "'onMouseOver=" . linkFTecnica(nref2) . ">";
-- or --
# assuming linkFTecnica is a perl function
$datos = $datos . "<a href='$me?C=OFERTAS2&EMPRESA=$empresa_param&NREF=$nref' onMouseOver=" . linkFTecnica(nref2) . ">";
-- or --
# Assuming that linkFTecnica is a JS function (which it probably is)
$datos = $datos . "<a href='$me?C=OFERTAS2&EMPRESA=$empresa_param&NREF=$nref' onMouseOver=linkFTecnica(nref2)>";
The difference between my code and yours is that you’re using “” for some reason to open and close your string. Are you trying to escape them or something? If so, you want to use " instead of “”
Also, remember that when you put a scalar variable within double quotes that it gets expanded.
$x = "test";
$y = "This is a $x";
results in $y being “This is a test”. If you get into problems like this
$x = "test";
$y = "This_is_a_$x_with_underscores"
you will need to resolve it in one of the following ways