Skip to main content
Question

Help with jQuery for Select All checkbox

  • 5 June 2024
  • 0 replies
  • 26 views

I have a form with 10 checkboxes that users would like a Select All checkbox added so they don’t have to check all ten manually:

I have tried adding jQuery to get it to work but nothing seems to work.  I have named (not control name but Javascript named) the Select All checkbox to chkSelectAll and all 10 of the other checkboxes are  chkDay.  Here is my Javascript:

 

NWF.FormFiller.Events.RegisterAfterReady(function () {
    //when Select All checkbox is changed 
    NWF$("#" + chkSelectAll).on("change", function(event){
        var isChecked = NWF$(event.target).prop("checked");
        // if Select All checkbox is checked
        if (isChecked) {
            // all Day checkboxes get checked 
                NWF$(':checkbox.chkDay').prop('checked', this.checked);
        }


        //uncheck Select All checkbox
        NWF$("#" + chkSelectAll).prop("checked", false);
    });
});

 

TIA,

Dawn

0 replies

Be the first to reply!

Reply