prohor Posted May 13, 2018 Share Posted May 13, 2018 I am trying to learn php and js. Here I am trying to put a value in php varible from javascript alert message input box but failed.here what I have done so far, // <?PHP and other variable is here.... $number='number'; <script> function number{ if (fail == "") { number = prompt('Please enter Phone Number') if (number == "" || number == null) { alert(' You have not specified the Phone Number. Please try again.'); return false; } else { document.getElementById("number").value; return true; } } else { alert(fail); return false; } } </script> So, actually how I can store the value from js alert to php varible? help me. Thanks for your valuable time and opinion. Quote Link to comment https://forums.phpfreaks.com/topic/307273-how-to-get-value-from-js-alert-message-to-store-in-php-varible/ Share on other sites More sharing options...
denno020 Posted May 13, 2018 Share Posted May 13, 2018 (edited) The only way to get a value from JS to your PHP is to send a request from the JS to your server. This could either be through a form submission or an AJAX request PHP is run on the server, whereas JS is run on the client, essentially 2 completely different places that each have no idea about the other. Edited May 13, 2018 by denno020 Quote Link to comment https://forums.phpfreaks.com/topic/307273-how-to-get-value-from-js-alert-message-to-store-in-php-varible/#findComment-1558415 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.