# Count checked checkboxes in node-red dashboard

**URL:** <https://discourse.nodered.org/t/count-checked-checkboxes-in-node-red-dashboard/5749>\
**Category:** Dashboard\
**Created:** [13 December 2018 08:30 UTC](https://discourse.nodered.org/t/count-checked-checkboxes-in-node-red-dashboard/5749 "2018-12-13T08:30:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Partyarti](https://avatars.discourse-cdn.com/v4/letter/p/b19c9b/32.png) [@Partyarti](https://discourse.nodered.org/u/Partyarti)\
**Post date:** [13 December 2018 08:30 UTC](https://discourse.nodered.org/t/count-checked-checkboxes-in-node-red-dashboard/5749/1 "2018-12-13T08:30:09Z")

</div>

Hello, I´m using the node-red dashboard for a cocktailmachine.  
First I need to select 10 from 20 ingredients with checkboxes from the form-node. Can I count the selected checkboxes before submitting the values?

Is it also possible with switches from the form-node?

If no, how can I count them after submitting?

Thank´s for helping

---

<div class="post-metadata">

**Author:** ![hugobox](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hugobox/32/2948_2.png) [@hugobox](https://discourse.nodered.org/u/hugobox)\
**Post date:** [16 December 2018 05:21 UTC](https://discourse.nodered.org/t/count-checked-checkboxes-in-node-red-dashboard/5749/2 "2018-12-16T05:21:34Z")

</div>

Hi Partyarti!  
A cocktailmachine sounds awesome! Using the form-node you can't easily count the selected checkboxes before submitting. You'd have to create a ui-template that parses your html and count the md-icons that have been selected.

Counting after submitting is much easier, you could use a function node with the following:

```auto
let count = 0
for (let x in msg.payload) {
    if (msg.payload[x] === true){
        count++
    }
}
msg.count = count
return msg;

```

Another option would be using the split node followed by a switch node (set to: is true) followed by a node-red-contrib-message-counter node.

Cheers!
