CodeIgniter Forums

Full Version: Newbie Q: Populating a dropdown
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

Hey guys,

So the gyst of my issue is that I would like to have a user select a single account from a dropdown.

This will then populate a series of other dropdowns with what they have previously selected on another page for that individual account stored in MySQL database. So far I am able to populate the initial dropdown with the correct account information but I am having an issue with getting their other information into the dropdowns, while also populating these dropdowns with an array of other values. Basically I need something along the lines of:

They choose account1:
It should display for instance Value4, but then the dropdown should also have Value1, Value2, Value3 etc. as options in the dropdown list. If they choose account2 from the inital dropdown it should then populate a different value from the database based on those for account2.

I've done some cursory searching but so far I haven't found anything like this. Can someone point me to a good reference other than the user guide? I'm not having much luck so far. I can include what I have so far but I'm not sure that it's very worthwhile.

Thanks in advance!

El Forum

You may want to consider doing an Ajax call that is triggered by the onchange event of the first dropdown. Are you familiar with jQuery?

El Forum

If you google "codeigniter dependent dropdown" you will find lots of examples on how to do it.

El Forum

I appreciate the feedback guys. I had found some this before but I think my lack of javascript experience is making this seem more daunting than it actually is. I'll put in some time and see what I come up with. Thanks for the help!