loren646 Posted February 22, 2013 Share Posted February 22, 2013 (edited) i have two combo boxes that are populated with data from mySQL. combobox_ONE has landlords. combobox_TWO has buildings. however, I want a user to be able to select a landlord from combobox_ONE and on select combo_TWO is populated with buildings owned by that specific landlord. Could this be done in php (without a button just on select)? or do i have to do javascript? Edited February 22, 2013 by loren646 Quote Link to comment https://forums.phpfreaks.com/topic/274806-possible-want-one-combobox-to-populate-another-combo-box/ Share on other sites More sharing options...
Jessica Posted February 22, 2013 Share Posted February 22, 2013 Yes, it's javascript. Specifically, AJAX. jQuery has a great tool for AJAX. Quote Link to comment https://forums.phpfreaks.com/topic/274806-possible-want-one-combobox-to-populate-another-combo-box/#findComment-1414070 Share on other sites More sharing options...
Psycho Posted February 22, 2013 Share Posted February 22, 2013 If the lists of total landlords and total properties is "reasonable" then you can accomplish it with just javascript by writing all the data as Javascript variables into the page. But, yeah, if you want this to happen without doing a page refresh then you have to do it with javascript and the only question is if you are going to make a trip back to the server (AJAX) or do it completely client side. Quote Link to comment https://forums.phpfreaks.com/topic/274806-possible-want-one-combobox-to-populate-another-combo-box/#findComment-1414086 Share on other sites More sharing options...
StevenFullman Posted February 22, 2013 Share Posted February 22, 2013 (edited) Hi there, PHP does nothing after the output has been sent (it's a pre-processor), so there's no 'onchange' event you can call. As the others have said AJAX is the way to go. jQuery would probably be the easiest option. I've been using this plugin recently: http://www.appelsiin...rojects/chained It does exactly what you need, and is more intuitive than other similar ones I've seen. Cheers, Steve Edited February 22, 2013 by StevenFullman Quote Link to comment https://forums.phpfreaks.com/topic/274806-possible-want-one-combobox-to-populate-another-combo-box/#findComment-1414110 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.