[Javascript] JavaScript to PHP variable transfer

Mike Dougherty mdougherty at pbp.com
Thu Aug 21 11:54:01 CDT 2003


Why are you attempting to do this?  I don't understand why you wouldn't
submit your value back to the server over a normal transport mechanism
(either post, or via cookie) and have the receiving page process that
value in the usual way.  Knowing the intended use might help solve this
problem, or propose a more easily implemented solution.

-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu] On Behalf Of David Lovering
Sent: Thursday, August 21, 2003 11:30 AM
To: [JavaScript List]
Subject: Re: [Javascript] JavaScript to PHP variable transfer


Well, maybe not.  "x$" becomes an implicit executable, and not a regular
string.  Not good!  I'm still looking for a way to take the output of a
JavaScript directive and pipe it (or use I/O redirection, or something
similar) in order to plant it in a regular, editable PHP variable.  I've
tried various flavors of the PHP routine eval, and so far there is no
joy.

Help!  Mind growing numb!

-- Dave Lovering

----- Original Message ----- 
From: "David T. Lovering" <dlovering at gazos.com>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Wednesday, August 20, 2003 3:20 PM
Subject: [Javascript] JavaScript to PHP variable transfer


>
> In regards to my previous posting, I tried something so simple that it
had
earlier eluded my consideration, and lo and behold, it worked!  The
method
(if done elegantly) requires two routines -- one in JavaScript, and one
in
PHP:
>
> <html>
> <head>
>   <title> bogus </title>
>   <script language='JavaScript'>
>   <!--
>     var myVal = 'happy, happy!';
>
>     function getvariable(val) {
>       var dummy = eval(val);
>       document.write(dummy);
>     }
>   // -->
>   </script>
>   <?php
>     function get_JS_var($js_var_name) {
>       $x = "<script> getvariable('" . $js_var_name . "'); </script>";
>       return $x;
>     }
>   ?>
> </head>
> <body>
>   <form name='myForm' action='javascript:void(null)'>
>     <?php
>       $abc = get_JS_var("document.forms[0].name");
>       $def = get_JS_var("myVal");
>     ?>
>     <center><?php print "abc: " . $abc; ?></center><br>
>     <center><?php print "def: " . $def; ?></center><br>
>   </form>
> </body>
> </html>
>
> As you can see should you try it, the method works fine -- both for
static
variables,
> and for JavaScript objects.  I imagine something similar could be made
to
work for
> PERL, Python, etc.
>
> -- Dave Lovering
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
>


_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list