# Dashboard \> Template Node \> Table has rows with checkboxes. Example of a "CheckAll"

**URL:** <https://discourse.nodered.org/t/dashboard-template-node-table-has-rows-with-checkboxes-example-of-a-checkall/49851>\
**Category:** Dashboard\
**Created:** [17 August 2021 17:49 UTC](https://discourse.nodered.org/t/dashboard-template-node-table-has-rows-with-checkboxes-example-of-a-checkall/49851 "2021-08-17T17:49:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![twack](https://avatars.discourse-cdn.com/v4/letter/t/df705f/32.png) [@twack](https://discourse.nodered.org/u/twack)\
**Post date:** [17 August 2021 17:49 UTC](https://discourse.nodered.org/t/dashboard-template-node-table-has-rows-with-checkboxes-example-of-a-checkall/49851/1 "2021-08-17T17:49:05Z")

</div>

Hi folks,

I have a table in a UI Template Node that contains a list of items. The list is long so I would really like to implement "Check All / Uncheck All" functionality using a checkbox contained within the header row. Does anyone have an example?

TIA

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [17 August 2021 18:06 UTC](https://discourse.nodered.org/t/dashboard-template-node-table-has-rows-with-checkboxes-example-of-a-checkall/49851/2 "2021-08-17T18:06:19Z")

</div>

```auto
<div>
  <input type="checkbox" onClick="toggle(this)">Toggle All</input><br>

  <input type="checkbox" name="checkbox" value="bar1">Bar 1</input><br>
  <input type="checkbox" name="checkbox" value="bar2">Bar 2</input><br>
  <input type="checkbox" name="checkbox" value="bar3">Bar 3</input><br>
  <input type="checkbox" name="checkbox" value="bar4">Bar 4</input><br>
</div>

<script language="JavaScript">
  function toggle(source) {
  let checkboxes = document.getElementsByName('checkbox');
  checkboxes.forEach( el => {
          el.checked = source.checked;
  } )
}
</script>

```

**Explanation** :

1. we trigger the `toggle` function with `onClick` event
2. passing in the function `this` .. which in this case is the checkbox `Toggle All`
3. we get all the `checkboxes`
4. we loop through them with `forEach` and set each elements check state  
to the state of of the `Toggle All` element.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [31 August 2021 18:06 UTC](https://discourse.nodered.org/t/dashboard-template-node-table-has-rows-with-checkboxes-example-of-a-checkall/49851/3 "2021-08-31T18:06:35Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
