HI, Luo, good day to you.
on my site I'm looking to this setup :
clicking the main checkboxes, it should select the parents or related checkboxes. [ 2 cases here ]
1. main checkboxes select related ALL parent taxonomies
2. main checkboxes checked and select the " coded" checkboxes.
Pls, use the credentials you have, my updated site available to test for you. thank you.
for the above
1. selecting Taxonomies "West Region Districts" should also select all the below related checkboxes D22,23,24
2. selecting Special Rooms : "+1" should also select "Ground Floor Bedroom "
thanks.
HI Luo. i tested to get the feedback if any but none . my code below just to test the action- click from select checkbox
// auto check when main checkbox selected
function check_district(){
if($('input[value="west-region-districts"]').attr('selected') == true)
//document.getElementById("in-district-83").checked = true;
{
alert("West");
}
else { alert("No West"); }
}
Ok. i am able to check and select related but cant do vise versa. in this case , deselect to deselect all options. pls advice on this. thanks
jQuery(document).ready(function($) {
$('input[name="wpv-district[]"]').on('change', function(){
if($('input[name="wpv-district[]"]:checked').length > 0){
$('#in-district-84').attr('checked', 'checked');
}
})
});
Dear C6410,
I just got this ticket, since it is a custom JS codes problem, please provide a test site with same problem in below "private detail box", also point out the problem page URL and where I can edit your JS codes. I need to debut it in a live website, thanks
Q1) selecting Special Rooms : "+1" should also select "Ground Floor Bedroom "
I added below JS codes in your view, section "Filter Editor", at the end of "JS editor" window:
jQuery(document).ready(function($) {
$('input[value="+ 1"]').on('change', function(){
if($('input[value="+ 1"]:checked').length > 0){
$('input[value="Ground Floor Bedroom"]').attr('checked', 'checked');
}
})
})
Q2) selecting Taxonomies "West Region Districts" should also select all the below related checkboxes D22,23,24
I have removed your JS codes, and added below JS codes:
jQuery(document).ready(function($) {
$('input[value="west-region-districts"]').on('change', function(){
if($('input[value="west-region-districts"]:checked').length > 0){
$('#in-district-84').attr('checked', 'checked');
$('#in-district-85').attr('checked', 'checked');
$('#in-district-86').attr('checked', 'checked');
}
else{
$('#in-district-84').removeAttr('checked');
$('#in-district-85').removeAttr('checked');
$('#in-district-86').removeAttr('checked');
}
})
})
Please test again, check if it is fixed.
Thanks Luo, its working great but just for coding performance is there any way to shorten this ?
i worry the code will be longer given my taxonomies structure 🙂
$('#in-district-84').attr('checked', 'checked');
$('#in-district-85').attr('checked', 'checked');
$('#in-district-86').attr('checked', 'checked');
thanks.
Hi LUo. is there anyway i could use this at the backend as well ?
thanks
Q1) is there any way to shorten this ?
You can try with Multiple Selector, for example:
$('#in-district-84, #in-district-85, #in-district-86').attr('checked', 'checked');
More help:
enlace oculto
Q2) is there anyway i could use this at the backend as well ?
No, there isn't such a built-in feature within Types plugin, if you agree we can take it as a feature request.
sorry i didnt read the last reply. can we proceed to submit the part2 for feature request ? thanks