CodeIgniter Forums
pls help me with chain select with category and subcat in codeigniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: pls help me with chain select with category and subcat in codeigniter (/showthread.php?tid=38864)



pls help me with chain select with category and subcat in codeigniter - El Forum - 02-21-2011

[eluser]dhaulagiri[/eluser]
please help me how to create dropdown select menu in CI, where if i select category then sub categor will appear on the same page withour refreshing browser. Thanks


pls help me with chain select with category and subcat in codeigniter - El Forum - 02-22-2011

[eluser]duellsy[/eluser]
Give this a read over, see if it helps

http://www.subooa.com.au/blog/development/jquery/switching-associated-select-lists-with-jquery/


pls help me with chain select with category and subcat in codeigniter - El Forum - 02-22-2011

[eluser]alexaaaaaaaaaa[/eluser]
i've done that with prototype if you are interested i can share my code m+c+v +database


pls help me with chain select with category and subcat in codeigniter - El Forum - 02-22-2011

[eluser]masdevid[/eluser]
[quote author="duellsy" date="1298392051"]Give this a read over, see if it helps

http://www.subooa.com.au/blog/development/jquery/switching-associated-select-lists-with-jquery/[/quote]

What about in codeigniter version? What if there are 3 level or more?


pls help me with chain select with category and subcat in codeigniter - El Forum - 02-22-2011

[eluser]alexaaaaaaaaaa[/eluser]
[quote author="masdevid" date="1298422685"][quote author="duellsy" date="1298392051"]Give this a read over, see if it helps

http://www.subooa.com.au/blog/development/jquery/switching-associated-select-lists-with-jquery/[/quote]

What about in codeigniter version? What if there are 3 level or more?[/quote]

The basic as i know it's to create a function somethin' like this
controller_name/3
where 3 it's the id and you'll get all the subcateg with the parent_id 3
egs. paris,roma,london has parent_id 3 in the country list you have France with the id 3
and so on then when you move to the jquery the things are simple i think
you wrap the options list into a div with and id and onchange you call a js function that will get the dom the content of the that div id.
As i told you i'm not very exp with jquery but i think if you take a look over the Json u'll understand it very well.
Here's a link with some screen casts http://www.weblee.co.uk/ the guy it's great you can learn jquery basis and codeigniter.
Regards,
Alex


pls help me with chain select with category and subcat in codeigniter - El Forum - 02-22-2011

[eluser]masdevid[/eluser]
[quote author="alexaaaaaaaaaa" date="1298423772"][quote author="masdevid" date="1298422685"][quote author="duellsy" date="1298392051"]Give this a read over, see if it helps

http://www.subooa.com.au/blog/development/jquery/switching-associated-select-lists-with-jquery/[/quote]

What about in codeigniter version? What if there are 3 level or more?[/quote]

The basic as i know it's to create a function somethin' like this
controller_name/3
where 3 it's the id and you'll get all the subcateg with the parent_id 3
egs. paris,roma,london has parent_id 3 in the country list you have France with the id 3
and so on then when you move to the jquery the things are simple i think
you wrap the options list into a div with and id and onchange you call a js function that will get the dom the content of the that div id.
As i told you i'm not very exp with jquery but i think if you take a look over the Json u'll understand it very well.
Here's a link with some screen casts http://www.weblee.co.uk/ the guy it's great you can learn jquery basis and codeigniter.
Regards,
Alex[/quote]


Thanks for reply, I already found it by myself before I read your reply. Little modification from this site http://www.subooa.com.au/blog/development/jquery/switching-associated-select-lists-with-jquery/
Code:
jQuery('#level1').change(function(){
    $level1_chosen = jQuery('#level1 option:selected').val();
    if(jQuery('#level2_lists #level2_' + $level1_chosen).length == 0){
        $level1_chosen = 'empty';
    }
    jQuery('#level2').html(jQuery('#level2_lists #level2_' + $level1_chosen).html());
    jQuery ('#level2').change(function(){
        $level2_chosen = jQuery('#level2 option:selected').val();
        if(jQuery('#level3_lists #level3_' + $level2_chosen).length == 0){
            $level2_chosen = 'empty';
        }
        jQuery('#level3').html(jQuery('#level3_lists #level3_' + $level2_chosen).html());
    });
});
Thanks for the link too, I need some page to bookmarked.