Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript vars into Perl Script

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
I need to pass a var from a Javascript into a perl script but how?
I have been trying the FAQ's for a few days but cannot acess them.


Keith
 
Easiest way is to have a hidden form variable you can access and set from JS that gets posted to Perl with the rest of the form.

________________________________________
Andrew

I work for a gift card company!
 
== Belongs in Javascript forum really
yea, and if you are computing them on the fly in your javascript, you can use the DOM to define form values dynamically. Something like:

<form name="sweet" action="whatever">
<input type="hidden" name="foo" value="" />
<input type="button" value="Click" onClick='document.sweet.foo.value = "bar";' />
</form>
==

Then, as icrf indicated, just retrieve that value as a normal CGI parameter.

--jim
 
I've actually become kind of a fan of document.getElementById() as it seems to be pretty well supported (and form names in .NET don't mean so much as they used to). But still, that's a stylistic JS issue.

Just be sure to check whatever you set in JS server-side in Perl as well. I've run into JS-calculated totals being taken as real totals before, a big no-no.

________________________________________
Andrew

I work for a gift card company!
 
I wasn't sure which forum to post into but hoped that someone would be able to help. A Javascript function creates a hidden var which is posted to the script in the normal way. One of those cases where the answer is simple when you know it.

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top