Jump to content

Checkbox that will select all items in a multi-select listbox


Recommended Posts

You can use the code below as a reference.

<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {

  var c_checkbox = document.getElementById("selectAll") ;
  var elementID = event.detail.uniqueSuffix; 

  function c_event () {
    if (c_checkbox.checked) {
      var listBox = document.getElementById('Value1_1' + elementID);
      for (i = 0; i < listBox.options.length; i++)
      	listBox.options[i].selected = true;
   }
   else {
      var listBox = document.getElementById('Value1_1' + elementID);
      for (i = 0; i < listBox.options.length; i++)
        listBox.options[i].selected = false;
    }
  }

  c_checkbox.onclick = c_event;
});
</script>

 

Add this in your search's footer with the HTML editor being disabled. Just make the necessary changes for your form elements' ID attribute. You may use this guide for that.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...