Forum Moderators: coopster

Message Too Old, No Replies

Getting JS variable content into PHP variable

         

aakk9999

11:06 am on May 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have javascript that converts currencies.
The euro price is passed to the javascript, javascript picks up the currency from the drop down menu, calculates price in selected currency and returns the converted price. It uses getElementById.

I can display converted price in php by using the lines below.

echo "<script type=\"text/javascript\">var eurprice = $eurprice;</script>";
echo "<p id=\"conv_price\" class=\"fltL\" style=\"margin-right:0;width:72px;\"></p>";

What I would like to do is to move the content of the returned js variable conv_price into a php variable $conv_price

eg. $conv_price = ? (to be able to set to content of the conv_price variable returned by JS)

Any ideas ?

Many thanks

PHP_Chimp

12:48 pm on May 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No. As the javascript will do its work in the browser. PHP does its work on the server.
So anything that javascript does will be done after the code has left the control of php.

You could use AJAX to get javascript and php talking together, but plain javascript doesnt talk to the server.

aakk9999

1:03 pm on May 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



ok, many thanks on explanation