f6100153 Posted February 18, 2011 Share Posted February 18, 2011 I have a form that looks like this: <form method="get"> Postcode:<input name="Postcode" type="text"><br> Name:<input name="Name" type="text"><br> <a href="#" onclick="popup('popUpDiv')">Find Agent</a> <input name="ID" type="hidden"> <input name="Employee_Name" type="hidden"> <input name="Submit" type="submit"> </form> The pop up Div has a Mysql query thats search for available agents that cover the postcode entered in postcode textarea, at the moment the only way I can get this work is by having another submit button which submits the postcode and to the same page. Is there a way use what is entered in the postcode textarea as a php variable without doing a page submit first?? Thanks in advance Tom Quote Link to comment https://forums.phpfreaks.com/topic/228095-help-php-form-problems/ Share on other sites More sharing options...
KevinM1 Posted February 18, 2011 Share Posted February 18, 2011 Not with PHP itself. By the time you see the web page, PHP is done running. It won't 'see' form values unless they're submitted. You'll need to use JavaScript and Ajax to grab the text field's value and pass it back to the PHP script for processing. Quote Link to comment https://forums.phpfreaks.com/topic/228095-help-php-form-problems/#findComment-1176224 Share on other sites More sharing options...
f6100153 Posted February 18, 2011 Author Share Posted February 18, 2011 Thanks Nightslyr, Do you anywhere where I could find an example of how to do that? I've used javascript a little but not much experience with AJAX Quote Link to comment https://forums.phpfreaks.com/topic/228095-help-php-form-problems/#findComment-1176229 Share on other sites More sharing options...
KevinM1 Posted February 18, 2011 Share Posted February 18, 2011 The easiest, most straightforward way to do it would be by using jQuery. Otherwise you have to go through all the hoops of doing all the tedious low-level work yourself. That said, it is a good idea to see exactly how it works under the hood, even if you're not going to go that route. So, look at jQuery first to see how easy it can be, and then look up a tutorial on Ajax and JSON for the details. Google will provide all of what you need if you search. Quote Link to comment https://forums.phpfreaks.com/topic/228095-help-php-form-problems/#findComment-1176236 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.