Forum Moderators: coopster

Message Too Old, No Replies

How ot pass java script variables to external php file?

Need to pass two variables from client side javascript to external php file

         

ron_isc

11:49 pm on Apr 3, 2003 (gmt 0)

10+ Year Member


Does anyone know of a way to pass a javascript variable to an external php file. The javascript is located in the html body and is client side. The two variables that need to be passed are both float values. Writing and reading the values from a text file will not work as the code is located on a template and several files could possibly access the text file at the same time. Any help would be greatly appreciated.
Thanks in advance!

GeorgeGG

12:11 am on Apr 4, 2003 (gmt 0)

10+ Year Member



Try something like:
<script TYPE="text/javascript">

// one line
document.write("<script type=\"text/JavaScript\"
src=\"http://www.#####.###/file.php
?A="+escape(js_val1)+"&B="+escape(js_val2)+"\">
</"+"script>");

</script>

GeorgeGG

ron_isc

12:42 am on Apr 4, 2003 (gmt 0)

10+ Year Member



When the variables are passed using this command the page displays for a second and then reverts to a blank screen. The url is still the same. When I view the source code this is all that is displayed. <script type="text/JavaScript" src="/msrp.php?A=149.99&B=119.00"></script>. The values of A and B are correct but I cannot figure out why it is not displaying the rest of the code. No php or javascript errors are present. All the php file does is display basic text output. Any Ideas?
Thanks,
Ron_isc