You are viewing limited content. For full access, please sign in.

Question

Question

Add select all option

asked on October 25, 2017 Show version history

HI,

 

we added radio button to forms as attached file , we need option to select all one, how we can add it ?

 

Best Regards,

Banan Aqraa

0 0

Replies

replied on October 26, 2017

Hey,

What you are looking for here is a bit of jquery. Since there is no information to go off for a tailored solution this should be generic enough to use. Just add the class "select-all" to the select all checkbox and add the class "check-group' to the checkboxes you want it to control.

$(document).ready(function() {
  $('.select-all input').change(function() {
    if($(this).is(':checked'))
    {
     $('.check-group input').prop('checked',true);
    }
    else
    {
      $('.check-group input').prop('checked',false);
    }
  });
  $('.check-group input').change(function() {
    if(!$(this).is(':checked'))
    {
       $('.select-all input').prop('checked',false);
    }
  });
  
});

I built this based off checkboxes, it should still work off radio buttons however id recommend using checkboxes as radio buttons don't make a lot of sense in the context of a select all button.

Hope this helps.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.