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?

Edited by loren646
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by StevenFullman
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.