colinsp Posted February 24, 2009 Share Posted February 24, 2009 Is it possible to get the value of an HTML input box on a form and assign it to a php variable without having a submit button on the form? Something like an after update? Or is this something that would have to be done in Javascript / Ajax etc. Sorry if this is a dumb question but I am trying to learn PHP by setting myself some challenges. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted February 24, 2009 Share Posted February 24, 2009 Well you need to remember that the form and data entered is client side (until its posted) and php is server side!.. So i would normally say yes via ajax BUT it the real question is what do you want to do ? if you wish to run any PHP code without reloading the page then ajax is probably what you want. Quote Link to comment Share on other sites More sharing options...
jackpf Posted February 24, 2009 Share Posted February 24, 2009 Well, if you wanted to achieve this without loading the page, then yes, you'd have to use ajax. However, if you simply wanted a form without a submit button, you could use javascript to submit the forum once a user changes something. For example, something like onkeyup="parentNode.submit()" Something like that anyway. Quote Link to comment Share on other sites More sharing options...
colinsp Posted February 24, 2009 Author Share Posted February 24, 2009 Thanks for your responses. I think that Ajax is a step too far for me at the moment I will make do with a submit button for now. I will look into Ajax in the coming months to see how to do it. Basically what I have is an input field that has its options populated from a query on a mysql database. When a user selects the option I want to perform a query on a second table and the result of this query is populated below it in a table as there will be multiple rows that match the selection. Any way thanks for your help. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted February 24, 2009 Share Posted February 24, 2009 Okay when your ready you may want to check this it MAY help Dynamic DropDown PHP/AJAX Topic Solved ? Quote Link to comment Share on other sites More sharing options...
colinsp Posted February 24, 2009 Author Share Posted February 24, 2009 Thanks that is very close to what I was looking for. I have copied the code and will experiment with it. Quote Link to comment 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.