[Javascript] JavaScript to PHP variable transfer

David Lovering dlovering at gazos.com
Thu Aug 21 11:29:56 CDT 2003


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
>
>




More information about the Javascript mailing list