kgiles
Scholar

Check All Check Boxes

Jump to solution

I have a Classic 2013 form with a cascading checkbox. 

I need to be able to Select All check box results. 

I've asked this question before but have yet to find an answer. Please help!

Describer:
1. Select Specialty. This control is a Choice Field with drop down selected. Java name "Specialty"

kgiles_0-1658931542504.png

2. A list of emails pops up. This control is a SharePoint List Lookup with check box (Multiple-Selection) selected. Java name "emailID"

kgiles_1-1658931618959.png

3. I have a checkbox on my form. Java name "SelectAll"

4. I would like to be able to check "SelectAll" and have all the email check boxes (emailID) checked. 

 

Please and thank you

0 Kudos
Reply
4 Replies
MegaJerk
Collaborator

Re: Check All Check Boxes

Jump to solution

This is pretty simple but includes some custom code so I will try to make it as simple as I can. 

 

I didn't want to try to recreate your lists for lookup exactly, and already had a list I use for dummy lookups called Fruits List, so I have created another list of Fruit Experts who all have some amount of Fruits associated to them via a Lookup:

MegaJerk_0-1658981698609.png

 

MegaJerk_1-1658981703086.png

 

The Fruit Experts List Titles will stand in for the "EmailID" emails on your form

 

Speaking of forms, I have made a dummy form close to what I've seen of yours:

MegaJerk_2-1658981755263.png

 

I've also configured the Controls to have the same JavaScript ID names as what you've given to your controls:

MegaJerk_3-1658981857639.png

 

Email IDs

MegaJerk_4-1658981904990.png

 

Select All checkbox

MegaJerk_5-1658981945425.png

 

The rest is pretty straight forward. Open up the Settings of your form using the Settings button in the Ribbon:

MegaJerk_6-1658982031399.png

 

Then expand the "Custom JavaScript" section, paste in the following code, and save:

 

NWF.FormFiller.Events.RegisterAfterReady(function () {
  NWF$("#" + Specialty).on("change", function(event){
    NWF$("#" + SelectAll).prop("checked", false);
  });

  NWF$("#" + SelectAll).on("change", function(event){
    var isChecked = NWF$(event.target).prop("checked");
    if (isChecked) {
      NWF$("#" + emailID).siblings("table").find("input:checkbox").each(function(index, checkbox){
        NWF$(checkbox).prop("checked", true);
      });
    }
  });
});

 

 

As Shown:

MegaJerk_7-1658982083513.png

 

The Results will be that now when your form is loaded, the Select All button should check all of the checkboxes in the emailID Control, and if you make a change to the Specialty (or in my case, fruit), it will uncheck the "Select All" checkbox:

MegaJerk_8-1658982215355.png

 

MegaJerk_9-1658982223373.png

 

MegaJerk_10-1658982236065.png

 

Let me know if you need further assistance. 

 

 

 

 

0 Kudos
Reply
kgiles
Scholar

Re: Check All Check Boxes

Jump to solution

That worked perfect! Thank you so much! I'm having one more tiny issue...

I have a Calculated Value Field, Java Name "EmalCalc" . 

It used to pull in the values when the check boxes were checked.  
Now that the Select All feature has been added, this isn't happening. I can still get it to work if I manually click on the check boxes. 
Here is the formula I am using. I need this to populate with all the emails when Select All is clicked. 

kgiles_1-1659012017162.png

Please and thank you! 

 

 

0 Kudos
Reply
MegaJerk
Collaborator

Re: Check All Check Boxes

Jump to solution

No need to do anything to that control, I just modified the code I gave you above to the following:

NWF.FormFiller.Events.RegisterAfterReady(function () {
  NWF$("#" + Specialty).on("change", function(event){
    NWF$("#" + SelectAll).prop("checked", false);
  });

  NWF$("#" + SelectAll).on("change", function(event){
    var isChecked = NWF$(event.target).prop("checked");
    if (isChecked) {
      NWF$("#" + emailID).siblings("table").find("input:checkbox").each(function(index, checkbox){
        NWF$(checkbox).prop("checked", true).trigger("change");
      });
    }
  });
});

 

It now has a trigger which indicates to the form that the control should update any dependencies, and should make your Calculated Control update correctly. 

 

Please mark this thread as solved if this concludes the answers to this problem.  

Reply
kgiles
Scholar

Re: Check All Check Boxes

Jump to solution

Woooohooo! That did it! Thank you so much!

0 Kudos
Reply