Checkboxes - automatically setting all options if the "All" checkbox is ticked | XM Community
Skip to main content

Hi, just wondering if someone can help, I have a multiple choice question and I am allowing multiple answers …

Is it possible that if a user selects the “All Applications” checkbox, that all the other checkboxes (with the exception of the Other option) are ticked automatically?

 

 

Yes, we can use JS click event on the option and check if the checked property is true or false; accordingly make other options check/ uncheck.


Try adding the below to the OnReady section of the question’s JavaScript:

var checkbox = '#'+this.questionId+' inpututype="checkbox"]';

jQuery(checkbox).change(function(){

if (jQuery(checkbox).eq(0).prop("checked") == true) {

jQuery(checkbox).eq(1).prop({'checked':true, 'disabled':true});
jQuery(checkbox).eq(2).prop({'checked':true, 'disabled':true});
jQuery(checkbox).eq(3).prop({'checked':true, 'disabled':true});
jQuery(checkbox).eq(4).prop({'checked':true, 'disabled':true});

}else{

jQuery(checkbox).eq(1).prop({'disabled':false});
jQuery(checkbox).eq(2).prop({'disabled':false});
jQuery(checkbox).eq(3).prop({'disabled':false});
jQuery(checkbox).eq(4).prop({'disabled':false});

}

});

 


Leave a Reply