Hi All,
I want to pass the value of java script variable in perl?
how can I do that.

Please help me.

Thanks

Recommended Answers

All 3 Replies

You cannot. JavaScript is client-side, Perl is server-side. The only thing a web page can do is request a Perl-driven page, and the Request is either GET (pass the values on the querystring) or Post (pass the values in a Form).

So a typical technique is to have a hidden element on the form, set its value via Javascript, and then submit the form.

if you could post a snippet, i'll reply an example of what tgreer is getting at.

Not sure which direction you want to pass, but if u want to pass from perl to javascript -- you write out javascript like this snippet:
printf ("var myVariable = %d;", 1);
If that prints inside a javascript section it would assign the value "1" to the variable.
If u want to pass from javascript to perl, try AJAX.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.