At 10:21 AM 7/7/02 -0400, Bruce Maston, M.D., J.D. wrote:
>Is there a way to convert a JavaScript variable into Perl?
Bruce, the question is a bit invalid or misstated or something. No offense
meant, only this is a bit of a misunderstanding I think... for all I know,
maybe on my part.
> In other words,
>you have a JavaScript function:
>function test(input_to_function) {
>$perlvariable = input_to_function;
>print "alert('$perlvariable'); #get an alert box showing the value
>print "$perlvariable\n"; #variable prints on page
>}
Javascript and Perl are programming languages. Generally - not always -
Perl is used on a web server and Javascript is bundled with a client, i.e.
it's part of the browser. So javascript code is sent to the browser as part
of the webpage, and executes when the page is rendered. This is a client
side event; happens on the visitor's computer when the browser program is
running and in particular when it is rendering the webpage.
OTOH, perl is generally used for server side programming which means that
before the web hosting co's computer sends a response of HTML etc.. back to
the client it may be running some perl - which may even be the thing that
creates the response, i.e. a dynamic webpage.
Therefore these are two different and unrelated platforms running on two
different and unrelated machines. They are of course related by the fact
that they're both involved in fulfillment of the one webpage request
originating with the client, replied to by the server, and then the reply
rendered by the client.
However in order to get these two dudes to talk to each other you have to
do something more. I have written perl pgms that create javascript code on
the fly... it just gets sent back to the client along with whatever other
page code is generated. I've also written javascript code within a webpage
that communicates back to a (server) CGI pgm. This is easily done by using
get, e.g.
http://mysite.com/cgi-bin/perlpgm.cgi?var1="mixing"&var2="platforms"
You can also communicate using post or path_info. Setting a cookie in the
javascript and then reading it from the next server call would be fine too,
albeit cookies are not as reliable.
The really cool thing about the web is there's so many different ways to
get a particular thing done. That's also a major frustration of web
development. Welcome. :)
hth,
Marty
--
SIMPL WebSite Creation: http://face2interface.com/Home/Demo.shtml
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]