Skip Navigation

[Resuelto] select related checkboxes

This support ticket is created hace 7 años, 2 meses. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Este tema contiene 10 respuestas, tiene 2 mensajes.

Última actualización por Akhil hace 7 años, 2 meses.

Asistido por: Luo Yang.

Autor
Mensajes
#571228

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.

#571232

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.

#571255

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");  }
  }

#571260

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');
      }
    })
});
#571283

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

#571321

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.

#571325

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.

#571421

Hi LUo. is there anyway i could use this at the backend as well ?

thanks

#571615

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.

#571618

Thank you .

#572392

sorry i didnt read the last reply. can we proceed to submit the part2 for feature request ? thanks