This requires Forms 11 Update 5 (Version 11.0.2311) or later, because prior to that, it was not possible to have a button on the form call a function in the sandboxed Javascript.
I have tested this successfully on version 11.0.2311.50553.
Add some checkbox fields to your form. Give them CSS Class name of selectAllCheckboxes.
Add a custom HTML element to your form, add this HTML to it:
<button onclick="markAllCheckboxes()">Mark All Checkboxes</button>
<br><br>
<button onclick="unmarkAllCheckboxes()">Unmark All Checkboxes</button>
Then add this script to the Javascript (JS) section of the form:
//When the button is clicked to mark all boxes, run this function.
//Loop through each field with the selectAllCheckboxes class, then loop through
//each checkbox on the field to lookup its value.
//Then set all values on the checkbox field.
window.markAllCheckboxes = function () {
var allCheckboxes = LFForm.findFieldsByClassName("selectAllCheckboxes");
allCheckboxes.forEach(function(el) {
var allCheckboxesOptions = el.options;
var allCheckboxesValues = [];
allCheckboxesOptions.forEach(function(el) {
allCheckboxesValues.push(el.value);
});
LFForm.setFieldValues(el, {value: allCheckboxesValues});
});
};
//When the button is clicked to unmark all boxes, run this function.
//Loop through each field with the selectAllCheckboxes class and clear all values.
window.unmarkAllCheckboxes = function () {
var allCheckboxes = LFForm.findFieldsByClassName("selectAllCheckboxes");
allCheckboxes.forEach(function(el) {
LFForm.setFieldValues(el, "");
});
};
Now you have two buttons that will mark all checkboxes or unmark all checkboxes on the form.
