2 dropdown menus when one is selected the other appears - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: 2 dropdown menus when one is selected the other appears (/showthread.php?tid=56748) |
2 dropdown menus when one is selected the other appears - El Forum - 01-16-2013 [eluser]the_unforgiven[/eluser] Hi I have 2 dropdowns like so Code: <div class="control-group" id="cat"> So i need some help creating that only the Category is visible to start with then the next dropdown appears based on the selection to start with and only needs to show relevant to the first option. Can anyone help me, I know jQuery going to be best and fastest option i know the logic but struggling to write it. Help greatly appreciated! The html for these dropdowns are Code: <label class="control-label" for="name">Category <span red;">*</span></label> 2 dropdown menus when one is selected the other appears - El Forum - 01-16-2013 [eluser]CroNiX[/eluser] You'd create an onChange event for the first dropdown and initially hide the second select. In that event, grab the selected value of that dropdown and use ajax to send it to a controller. That controller will return the possible values for the second dropdown based on the value sent. In the onComplete event of the ajax call, take the new dropdown values returned and replace the options for the 2nd dropdown, and then show() that dropdown. You should give your selects id's so you can easily grab the value, and also replace the options. They don't show up in your rendered code... You can google "javascript dependant select" for tons of tutorials and demos which should all work the same whether you use CI or not. 2 dropdown menus when one is selected the other appears - El Forum - 01-16-2013 [eluser]the_unforgiven[/eluser] Thanks CroNiX i will do that! Hopefully i will find a solution. |