Jump to content

Possible? want one combobox to populate another combo box


loren646

Recommended Posts

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?

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.