ProcessOnChange() expects to pass in a control/element which has been changed. so have you (correctly) passed in one of changed lookup checkboxes?
how do you make single checkbox checked? by directly setting its checked property?
if you did it by calling its .click() event, dependent calculations should be executed.
using the following code to set the value of a Form Variable
that's need not be very reliable.
at first, form variable might be recalculated out of your control by an indirect event. so despite you set it to some value, at some unknown point it might be recalculated to another value.
and at second, if you set its value by a javascript, it will not in turn cause to recalculate dependent formulas.
make the form variable rather dependent on an 'Sellect all' check box so that it recalculates on its change.
You should be able to accomplish what you want simply by triggering a 'change' event on the inputs of type "checkbox".
- Form -
All Controls:
Control (1) : Yes/No:
Control (2): Choice:
Control (3): Calculated Value:
Form Variable:
Rules:
Formatting for the Choice Controls:
Custom Javascript:
Copy / Paste Code:
NWF$("adata-controlname='checkAll_Toggle'] inputltype='checkbox']").on("change", function(event){
if (NWF$(event.target || event.srcElement).prop("checked")) {
NWF$(").prop("checked", true).trigger("change");
}
});
How does it work?
It puts a "change" event handler on the 'Toggle All' Control. If you click on the toggle all control, it'll invoke the event handler.
Once the event is being handled by our code, we check to see if the Toggle All is being set to On or Off (true or false).
If it's true, then we get ALL of the inputs of type "checkbox" that are children to the "someChoices" control, and set them all to checked, and then trigger the change event on them, resulting in the form variable being updated, and the 'length' of the array being pushed to our Calculated Value Control immediately.
So....
On Load:
Two Items Checked:
Check All Checked:
I hope that this helps you accomplish what it is you're trying to do.
This is EXACTLY why I love this community so much! Thank you!
This was what I needed to get this project completed by Monday. I really appreciate your help, and that you went the extra mile to build out an example, include screenshots (with highlights), include your code (with a copy/paste section), and fully explain the entire process. Now this can easily help others as well!
I'm glad that it's going to help, and this is indeed a wonderful community!