Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Using javascript variable value in Perl script

Reply
Thread Tools

Using javascript variable value in Perl script

 
 
satish2112@gmail.com
Guest
Posts: n/a
 
      09-10-2007
I'm new to CGI and javascript.

I have a javascript variable which has a value assigned.

function UpdatePage()
{
var x=document.form100.TextArea1.value;
}

I want to use this value in perl script.

$input_string = "var"; - is this possible?

I know a way we can do - using form and submit action to pass the
javascript variable to the perl script.
Is there a way I can avoid using a click of button as an intermediate
step.(So that it is done in the backend and the same page exists)
Passing the value as a query string has a restriction of 1024
characters. I have content which
could be 3000 characters or more.

 
Reply With Quote
 
 
 
 
Erwin Moller
Guest
Posts: n/a
 
      09-10-2007
wrote:
> I'm new to CGI and javascript.


Welcome.

>
> I have a javascript variable which has a value assigned.
>
> function UpdatePage()
> {
> var x=document.form100.TextArea1.value;
> }
>
> I want to use this value in perl script.
>
> $input_string = "var"; - is this possible?


Not directly.
What happens in Javascript is not known to your Perl script on the
server, unless you make it known to the server.


>
> I know a way we can do - using form and submit action to pass the
> javascript variable to the perl script.


That would be the most straightforward way to pass it to the server indeed.

> Is there a way I can avoid using a click of button as an intermediate
> step.(So that it is done in the backend and the same page exists)
> Passing the value as a query string has a restriction of 1024
> characters. I have content which
> could be 3000 characters or more.


Yes there are other ways, mainly AJAX.
AJAX let you create an XMLhttpRequest-Object (whatever it is named in
different browsers). You can use this Object to post whatver you want to
a script, AND receive the response.

Read more here for a great hands-on introduction:
http://www.w3schools.com/ajax


And about the 1024 character limitation: I think you won't find a modern
webserver that holds this limit anymore.
But you can use POST too of course via AJAX, just to be sure.

Regards,
Erwin Moller
 
Reply With Quote
 
 
 
 
shimmyshack
Guest
Posts: n/a
 
      09-10-2007
On Sep 10, 11:46 am, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@spam yourself.com> wrote:
> satish2...@gmail.com wrote:
> > I'm new to CGI and javascript.

>
> Welcome.
>
>
>
> > I have a javascript variable which has a value assigned.

>
> > function UpdatePage()
> > {
> > var x=document.form100.TextArea1.value;
> > }

>
> > I want to use this value in perl script.

>
> > $input_string = "var"; - is this possible?

>
> Not directly.
> What happens in Javascript is not known to your Perl script on the
> server, unless you make it known to the server.
>
>
>
> > I know a way we can do - using form and submit action to pass the
> > javascript variable to the perl script.

>
> That would be the most straightforward way to pass it to the server indeed.
>
> > Is there a way I can avoid using a click of button as an intermediate
> > step.(So that it is done in the backend and the same page exists)
> > Passing the value as a query string has a restriction of 1024
> > characters. I have content which
> > could be 3000 characters or more.

>
> Yes there are other ways, mainly AJAX.
> AJAX let you create an XMLhttpRequest-Object (whatever it is named in
> different browsers). You can use this Object to post whatver you want to
> a script, AND receive the response.
>
> Read more here for a great hands-on introduction:http://www.w3schools.com/ajax
>
> And about the 1024 character limitation: I think you won't find a modern
> webserver that holds this limit anymore.
> But you can use POST too of course via AJAX, just to be sure.
>
> Regards,
> Erwin Moller


<script type="text/javascript">
var x=document.form100.TextArea1.value;
document.write( '<img src="/path/to/script.pl?x='+x+'" />' );
</script>

even better would be to use DOM manipulation instead of document.write
and use a perl script diguised as a jpeg:

'<img src="/path/to/perl_script.jpg?x='+x+'" />'
which returns a normal jpeg, so that the web bug is not noticed. (you
will have to send no cache headers to force the joeg to be requested
from the server each time)

even better than that would be to use rewrites so that the data is not
sent as a get parameter.
'<img src="/path/to/'+x+'/perl_script.jpg" />'

You could also use frames etc.. etc...


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing a variable's value from javascript to a perl script satish2112@gmail.com Javascript 3 09-04-2007 02:58 PM
Problem in passing values to perl script using another perl script vikrant Perl Misc 4 08-10-2005 06:20 PM
problem calling perl script from SOAP server perl script pj Perl Misc 3 04-09-2004 10:23 PM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM
How to make Perl Script "POST" call from another Perl Script??? Wet Basement Perl 1 07-15-2003 10:25 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57