Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   How I can execute Javascript into Perl? (http://www.chiefdelphi.com/forums/showthread.php?t=48699)

TomS 22-08-2006 07:23

How I can execute Javascript into Perl?
 
"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)"">"";

What is bad in this code?

Thank you very much. "

Ryan M. 22-08-2006 07:28

Re: How I can execute Javascript into Perl?
 
Are you trying to get the Javascript to execute inside of perl program or just trying to have the perl program output javascript? I'm a tad confused. :)

Noah Kleinberg 22-08-2006 15:39

Re: How I can execute Javascript into Perl?
 
Quote:

Originally Posted by TomS
$datos=$datos.""<a href='"" . $me . ""?C=OFERTAS2&EMPRESA="".$empresa_param.""&NREF="" .$nref.""' onMouseOver=""linkFTecnica(nref2)"">"";

What is bad in this code?

Is the 'linkFTecnica' function in the javascript, or is it a perl function?

If it is a perl function, then you need
Code:

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"

Hope this helped.

Dave Scheck 22-08-2006 16:35

Re: How I can execute Javascript into Perl?
 
Do you get an error that looks something like this?
Code:

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
Code:

# 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.
Code:

$x = "test";
$y = "This is a $x";

results in $y being "This is a test". If you get into problems like this
Code:

$x = "test";
$y = "This_is_a_$x_with_underscores"

you will need to resolve it in one of the following ways
Code:

$x = "test";
$y = "This_is_a_" . $test . "_with_underscores";
$y = "This_is_a_${x}_with_underscores";

Hope that points you in the right direction.


All times are GMT -5. The time now is 18:45.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi