ChaosKnight Posted December 23, 2009 Share Posted December 23, 2009 Hi all, I'm busy with a website for a South African tourism company, they want the bookings system to be very user-friendly, so I made a few dropdowns in PHP, but now comes the hard part for me, I have to create a onchange event and use Ajax to send the server request and database query, and retrieve the content and then use it in the next drop down... So basically it's a country dropdown, and after that follows the province/state dropdown and it's content should be relative to that of the country, and then again for the towns... There isn't any code that I think will be of use, only PHP echoes for a HTML form and select boxes, if you need anything else I'll be happy to post it.. Can you also please explain the Ajax I need in this situation, because I really want to know how Ajax works for any future projects requiring it Thanks, I really appreciate it! Chaos... Quote Link to comment https://forums.phpfreaks.com/topic/186182-dynamic-drop-down-iam-a-complete-ajax-newbie-need-help-urgently-please/ Share on other sites More sharing options...
trq Posted December 23, 2009 Share Posted December 23, 2009 Have you tried googling ajax tutorials or something? I'm not sure we really need to write another one just for you. Quote Link to comment https://forums.phpfreaks.com/topic/186182-dynamic-drop-down-iam-a-complete-ajax-newbie-need-help-urgently-please/#findComment-983328 Share on other sites More sharing options...
ChaosKnight Posted December 24, 2009 Author Share Posted December 24, 2009 Thanks for the reply, yes I also looked at Ajax in books like Head First Javascript and Javascript Bible, but most of them only return xml documents. I think what I need to do is make the first dropdown available, and when someone chooses an option I somehow have to use Ajax to add something like country=southafrica to the url, is that possible? Also, can I use Ajax to add the second and third dropdowns only when the previous dropdown changes? Thanks! Chaos Quote Link to comment https://forums.phpfreaks.com/topic/186182-dynamic-drop-down-iam-a-complete-ajax-newbie-need-help-urgently-please/#findComment-983526 Share on other sites More sharing options...
jon182 Posted December 24, 2009 Share Posted December 24, 2009 hmm w3schools.com or tizag.com might have some tutorials. Quote Link to comment https://forums.phpfreaks.com/topic/186182-dynamic-drop-down-iam-a-complete-ajax-newbie-need-help-urgently-please/#findComment-983567 Share on other sites More sharing options...
ChaosKnight Posted December 24, 2009 Author Share Posted December 24, 2009 Hi, thanks, I went through that tutorials after you sent your message, but now I just want to know if this will be possible: the php script already echoes the select element and query the database, but what I need to know is how do I send the variables using ajax to that php page and can I return the entire select with it's values and insert it into the page using Ajax? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/186182-dynamic-drop-down-iam-a-complete-ajax-newbie-need-help-urgently-please/#findComment-983589 Share on other sites More sharing options...
ignace Posted December 24, 2009 Share Posted December 24, 2009 Are you using any JS library like jQuery or YUI? If you don't I would highly recommend it especially jQuery, it has tons of plugins it's quite possible they have a plugin that does just that for you where you would pass the three id's (of your select) in sequence. Quote Link to comment https://forums.phpfreaks.com/topic/186182-dynamic-drop-down-iam-a-complete-ajax-newbie-need-help-urgently-please/#findComment-983605 Share on other sites More sharing options...
ignace Posted December 24, 2009 Share Posted December 24, 2009 et voila: http://remysharp.com/2007/09/18/auto-populate-multiple-select-boxes/ Told you someone already wrote it. Quote Link to comment https://forums.phpfreaks.com/topic/186182-dynamic-drop-down-iam-a-complete-ajax-newbie-need-help-urgently-please/#findComment-983607 Share on other sites More sharing options...
ChaosKnight Posted December 24, 2009 Author Share Posted December 24, 2009 Thanks for your reply... Is jQuery easy to use? Can you please give me an example on how to implement a jQuery plugin? Quote Link to comment https://forums.phpfreaks.com/topic/186182-dynamic-drop-down-iam-a-complete-ajax-newbie-need-help-urgently-please/#findComment-983679 Share on other sites More sharing options...
trq Posted December 24, 2009 Share Posted December 24, 2009 http://docs.jquery.com/Plugins/Authoring Quote Link to comment https://forums.phpfreaks.com/topic/186182-dynamic-drop-down-iam-a-complete-ajax-newbie-need-help-urgently-please/#findComment-983809 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.