hi friends can some one tell me How do I assign javascript variable to php variable? I am actually getting a value through javascript and I want the javascript values to be assigned to php variables. With out submitting the form.
Unless you are doing something really esoteric (such as running server side JS and PHP):
The PHP runs, generates a response, sends it to the browser. If that response includes JavaScript then that JS will then be executed.
You can't get data from the JS back to the PHP without issuing a new HTTP request.
This could be done by setting document.location
, adding an <img>
element to the document with the data passed via the src
attribute (in both cases including the data in a query string, posting a <form>
to an <iframe>
, using an XMLHttpRequest object and a host of other methods.
It really depends on what you want to achieve.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With