This topic contains 3 reply and 3 voices, and was last updated by Brennen 5 years, 9 months ago
Viewing 3 Posts - 1 through 3 (of 3 total)
Author Posts
December 4, 2013 at 11:47 am 13261
Brennen Hello support we want to display all the category as check box input, we have more than 250 categories having child parent relationship, so we need to display child categories only when parent category will be selected, so initially it will be a parent category list as check boxs and if any on the parent is selected we need that corresponding child category will start displaying. Thanks
December 4, 2013 at 1:49 pm 13268
Tareq Hasan Tareq Hasan

Paste this to your themes functions.php and see what happens.

[php]
function wpufe_show_hide_checkbox() {
?>
<script type="text/javascript">
jQuery(function($) {
var ul = $(‘.wpuf-category-checklist’);

ul.find(‘ul.children’).hide();

ul.on(‘click’, ‘input[type=checkbox]’, function(e) {
var check = $(this);
var child = check.closest(‘li’).children(‘ul.children’);

if ( child.lengh !== 0 ) {
if ( check.is(‘:checked’) ) {
child.show();
} else {
child.hide();
}
}
});
});
</script>
<?php
}

add_action( ‘wp_footer’, ‘wpufe_show_hide_checkbox’ );
[/php]

December 4, 2013 at 3:27 pm 13279
tbangun tbangun

Thanks Tareq, Works great 🙂

January 1, 2014 at 4:23 am 14080
Brennen Brennen

Hey Tareq this works great, one question: Can you update it so that if a parent is already checked the children show for that checked category only?

So basically on page load check if any parent categories are checked and if they are, show the children categories.

Viewing 3 Posts - 1 through 3 (of 3 total)