Dynamic Dropdowns based on prev selection - 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: Dynamic Dropdowns based on prev selection (/showthread.php?tid=56690) |
Dynamic Dropdowns based on prev selection - El Forum - 01-11-2013 [eluser]the_unforgiven[/eluser] I'm looking for some help on how to dynamically show dropdowns(DD)when a user goes to the page only the main categories should show in the DD then upon selection show another new DD that shows the sub-categories of the selected categeory. I know javascript/jQuery will be used here and after writing the following it still doesn't work so maybe i've done something wrong. The jQuery - http://jsfiddle.net/J9uFR/ The html - http://jsfiddle.net/5Ahek/ Would some one be kind enough to help me out here, maybe show an example based what ive done and explain what each does please.... Thanks in advance! Dynamic Dropdowns based on prev selection - El Forum - 01-11-2013 [eluser]boltsabre[/eluser] Try posting what your actual drop downs look like, hard to tell because you've posted "PHP" in the "HTML" jsfiddle, and obviously it's not rendering. But at a quick glance it looks like you have used the wrong selector here in your jQuery Code: $('.' + val).show(); You're trying to show something by its class (thats what the period selector is), but from what I can see you are generating your subcat DDs with IDs, not classes. Try using hash (#) instead, that's the ID selector in jQuery. Dynamic Dropdowns based on prev selection - El Forum - 01-11-2013 [eluser]the_unforgiven[/eluser] The html output is: Code: <div class="control-group" id="cat"> |