[Javascript] JavaScript to PHP variable transfer

David T. Lovering dlovering at gazos.com
Wed Aug 20 16:16:56 CDT 2003


I'm looking for a fairly simple method by which to write to a PHP variable on the server side from a JavaScript code module.  The reverse process is trivial:

	printf("<script> var myvariablename = 'howdy!'; </script>\n");

However, since there are issues of precidence (in the time-wise sense), the reverse strategy does not work.

Since I'm running MILSPEC code, the use of CGI/BIN POST/GET/PUT methods are completely out, and session-variable passing also.  Scratch everything you ever heard, read, or imagined regarding form variables.

I've explored the use of embedded PHP code in an IFRAME inside a 'span' directive, but the PARAMETER methods don't seem to generalize properly, particularly in the "uphill" sense -- from the IFRAME to variables within its parent.  Furthermore, if the
contents of the IFRAME are scrubbed (as per the location.href = "some-other-URL" method), the
variable cache also seems to go bye-bye.

One method that might give relief is so poorly documented that I can find little on how it might work in this context -- namely the object/class references in PHP.  In theory, JavaScript has a similar (albeit not a "pure" OOL) object structure, and one
could imagine that this might overlap at some level.

Any ideas out there?  This is a sticky one...

-- Dave Lovering


More information about the Javascript mailing list