Checkboxes set with JavaScript does not get saved to DB

Hi Team
I am trying to implement a requirement where a Checkbox type custom field will have an “ALL” option. The user could click on “ALL” option to select all the options with single click rather than have to select each checkbox. I have used JS to access the specific checkboxs and set them, so it appears as selected onscreen and also disabled.

<script>
require(["jquery"], function ($) {
	$(function() {
             $('#'+checkboxFieldId+'-1').change(function(){
             var value = $(this).is(':checked');
             for (var j = 2; j <= totalCheckBoxes; j++){
                  $('#'+checkboxFieldId+'-'+j).prop({
                          'checked' : value,
                          'disabled': true
                   });
             }
      }
}
</script>

This is done on create screen, but when viewed, only the “ALL” option shows, while rest of the values are not selected.

I need guidance to resolve this issue.

Thanks
Deepak

The check boxes which are marked as “disabled: true” will be treated as read-only so their checked value will not be saved. If it is required to save the checked value of boxes which are disabled, then the the check boxes have to be enabled before the issue create or update.

1 Like