hosker Posted September 29, 2011 Share Posted September 29, 2011 I have a form that I have data being pulled from a MySQL database and it is being put in a drop down list. Once the user selects something on the list, I would like specific data to be pulled from the database and displayed on the page without refreshing it. How would I go about doing that? Below is my code: <?php $query2="SELECT tournament,id FROM 2011_Tournament"; $result2=mysql_query($query2); echo "<select name=2011_Tournament value='tournament'>Tournament</option>"; while($tournament=mysql_fetch_array($result2)){ echo "<option value='$tournament[tournament]'>$tournament[tournament]</option>"; } echo "</select>";?> Quote Link to comment https://forums.phpfreaks.com/topic/248114-help-with-a-form/ Share on other sites More sharing options...
AyKay47 Posted September 29, 2011 Share Posted September 29, 2011 you will want your ajax function to be triggered by the "onchange" event to detect a change in the select value..for ajax script i recommend using jquery's AJAX API Quote Link to comment https://forums.phpfreaks.com/topic/248114-help-with-a-form/#findComment-1274067 Share on other sites More sharing options...
hosker Posted September 29, 2011 Author Share Posted September 29, 2011 Could you show me the code possibly for using "onchange"? Quote Link to comment https://forums.phpfreaks.com/topic/248114-help-with-a-form/#findComment-1274072 Share on other sites More sharing options...
AyKay47 Posted September 29, 2011 Share Posted September 29, 2011 YOU CAN FIND MANY EXAMPLES BY GOOGLING THE MATTER. Quote Link to comment https://forums.phpfreaks.com/topic/248114-help-with-a-form/#findComment-1274077 Share on other sites More sharing options...
hosker Posted September 29, 2011 Author Share Posted September 29, 2011 You're really going to yell at me. I have googled, I was just looking to talk to someone about the code do I can understand it better. Thanks for your help, or should I day lack thereof? Quote Link to comment https://forums.phpfreaks.com/topic/248114-help-with-a-form/#findComment-1274086 Share on other sites More sharing options...
AyKay47 Posted September 29, 2011 Share Posted September 29, 2011 i wsan't yelling, im at work and the work that I do is in caps.. sorry, i will talk about the code but i will not write code for you.. i do not have time for it atm Quote Link to comment https://forums.phpfreaks.com/topic/248114-help-with-a-form/#findComment-1274097 Share on other sites More sharing options...
hosker Posted September 29, 2011 Author Share Posted September 29, 2011 Ok, I understand. I'm not looking for the code to be written, just help in how to write it and understand it. Is there a specific place in the Jquery Ajax API code I should focus on? Quote Link to comment https://forums.phpfreaks.com/topic/248114-help-with-a-form/#findComment-1274099 Share on other sites More sharing options...
AyKay47 Posted September 29, 2011 Share Posted September 29, 2011 with jquery you will want to use the .change event handler http://api.jquery.com/change/ with this you can detect when a user changes to a different option in your select tag.. when they do, you can trigger an ajax function to handle the change and make it do whatever you want.. Quote Link to comment https://forums.phpfreaks.com/topic/248114-help-with-a-form/#findComment-1274106 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.