Skip to main content
July 23, 2016
Question

"Select all checkbox option?

  • July 23, 2016
  • 2 replies
  • 2228 views

This might be very obvious and I'm missing it, but is there an option in Forms with a checkbox for "Select all"?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

July 23, 2016

No there is not an option for this.  You would have to do this via javascript

SanfordWhiteman
Level 10
July 23, 2016

Add a checkbox with the value "*".  Then

MktoForms2.whenReady(function(form) {

  var formEl = form.getFormElem()[0],

    _forEach = Array.prototype.forEach,

    selCheckboxGroups = '.mktoCheckboxList',

    selWildcardBox = 'input[value="*"]',

    selStandardBoxes = 'input:not([value="*"])';

  (function makeSelectAll() {

    _forEach.call(formEl.querySelectorAll(selCheckboxGroups), function(boxGroup) {

      boxGroup.querySelector(selWildcardBox).addEventListener('change', function(e) {

        _forEach.call(boxGroup.querySelectorAll(selStandardBoxes), function(box) {

          box.checked = this.checked;

        }.bind(this));

      });

    });

  })();

});

Demo: http://s.codepen.io/figureone/debug/JKvRQv

July 25, 2016

Very cool thanks again Sanford!