+ 1

How to get script variable into php on same page?

I have a button "send" on clicking it, runs the function in script tag. Something like this...just ignore common syntax errors.. <Button onclick = test(variable) >send; <?php ?> <script > function test(userid) { Var id = userid; } </script> Now I want the "id" value in php tag.

23rd Nov 2019, 4:46 PM
Skelli Bro
Skelli Bro - avatar
1 Answer
+ 3
PHP code is executed on the server. The result is then displayed in the browser as plain HTML. Javascript is executed in the browser on the client. When Javascript runs on the client, the PHP tags are not available anymore. If you want to have the id available in PHP, you need to submit the form to the server and process the parameters there.
29th Nov 2019, 2:18 PM
Michal Straka
Michal Straka - avatar