CodeIgniter Forums
Newbie Q: Populating a dropdown - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Newbie Q: Populating a dropdown (/thread-56237.html)



Newbie Q: Populating a dropdown - El Forum - 12-04-2012

[eluser]Unknown[/eluser]
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!




Newbie Q: Populating a dropdown - El Forum - 12-04-2012

[eluser]apodner[/eluser]
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?


Newbie Q: Populating a dropdown - El Forum - 12-05-2012

[eluser]CroNiX[/eluser]
If you google "codeigniter dependent dropdown" you will find lots of examples on how to do it.


Newbie Q: Populating a dropdown - El Forum - 12-05-2012

[eluser]Unknown[/eluser]
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!