rmariano02 Posted May 28, 2013 Share Posted May 28, 2013 <INPUT TYPE='button' VALUE='Teest' onclick="myFunction()"> <script type = 'text/javascript'> function myFunction() { var x; var person=prompt("Please enter your feedback",""); if (person!=null) { <? $test = ""+person; ?> } } </script> <? echo"".$test; ?> Link to comment https://forums.phpfreaks.com/topic/278494-help-passing-the-value-of-javascript-to-php/ Share on other sites More sharing options...
dannon Posted May 28, 2013 Share Posted May 28, 2013 It is impossible to pass a JavaScript variable to PHP. JavaScript is executed on the client side (on your browser), and PHP is executed on the server side. Link to comment https://forums.phpfreaks.com/topic/278494-help-passing-the-value-of-javascript-to-php/#findComment-1432816 Share on other sites More sharing options...
rmariano02 Posted May 28, 2013 Author Share Posted May 28, 2013 is there a possible way to pass the values of javascript to PHP. what was my true goal is to insert the values from javascript promp and update my field into database. Link to comment https://forums.phpfreaks.com/topic/278494-help-passing-the-value-of-javascript-to-php/#findComment-1432819 Share on other sites More sharing options...
Q695 Posted May 28, 2013 Share Posted May 28, 2013 have the data submitted by a hyperlink with javascript pulling data to put it in the link? http://stackoverflow.com/questions/7850066/javascript-pass-variable-in-href-onclick-request Link to comment https://forums.phpfreaks.com/topic/278494-help-passing-the-value-of-javascript-to-php/#findComment-1432820 Share on other sites More sharing options...
dannon Posted May 28, 2013 Share Posted May 28, 2013 You can also use Ajax to send values to a PHP page which can insert those values into a database. You can also use jQuery which will be simpler solution. Have a look at this: http://api.jquery.com/jQuery.post/ Link to comment https://forums.phpfreaks.com/topic/278494-help-passing-the-value-of-javascript-to-php/#findComment-1432821 Share on other sites More sharing options...
Q695 Posted May 29, 2013 Share Posted May 29, 2013 I did it on a file where I passed the get array variable to the post array variable. This can get messy if you do it by the for each. Link to comment https://forums.phpfreaks.com/topic/278494-help-passing-the-value-of-javascript-to-php/#findComment-1433067 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.