# Help with Tallying Up Info from Checkboxes

**URL:** <https://forum.wixstudio.com/t/help-with-tallying-up-info-from-checkboxes/6483>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [July 23, 2018, 6:41pm UTC](https://forum.wixstudio.com/t/help-with-tallying-up-info-from-checkboxes/6483 "2018-07-23T18:41:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tgzegel](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@tgzegel](https://forum.wixstudio.com/u/tgzegel)\
**Post date:** [July 23, 2018, 6:41pm UTC](https://forum.wixstudio.com/t/help-with-tallying-up-info-from-checkboxes/6483/1 "2018-07-23T18:41:27Z")

</div>

Hi there,

I am trying to figure out how to create five checkboxes each with a specific value assigned to them. When a visiter clicks the checkboxes whichever has been clicked is added up and gives a total in a box below.

So basically I just need help figuring out how to assign a value to each checkbox and then how to connect them tp tally up everything.

Can anyone help me do this?

Thanks!

---

<div class="post-metadata">

**Author:** ![jeromechauveau](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@jeromechauveau](https://forum.wixstudio.com/u/jeromechauveau)\
**Post date:** [July 23, 2018, 8:34pm UTC](https://forum.wixstudio.com/t/help-with-tallying-up-info-from-checkboxes/6483/2 "2018-07-23T20:34:14Z")

</div>

Hi

This does the trick (did for 3, complete to as much as needed).

```javascript
$w.onReady(function () {
    $w("#checkbox1").value = "1";
    $w("#checkbox2").value = "2";
    $w("#checkbox5").value = "3";
   $w("#checkbox1").onChange( (event, $w) => {
        manageSum();
    } );
    $w("#checkbox2").onChange( (event, $w) => {
        manageSum();
    } );
    $w("#checkbox5").onChange( (event, $w) => {
        manageSum();
    } ); 
    manageSum();
});
 
function manageSum(){
 var sum = 0;
 if ($w("#checkbox1").checked) sum += Number($w("#checkbox1").value); 
 if ($w("#checkbox2").checked) sum += Number($w("#checkbox2").value); 
 if ($w("#checkbox5").checked) sum += Number($w("#checkbox5").value); 
 $w("#text18").text = ""+sum;
}

```

---

<div class="post-metadata">

**Author:** ![tgzegel](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@tgzegel](https://forum.wixstudio.com/u/tgzegel)\
**Post date:** [July 23, 2018, 8:39pm UTC](https://forum.wixstudio.com/t/help-with-tallying-up-info-from-checkboxes/6483/3 "2018-07-23T20:39:21Z")

</div>

Thank you so much for supplying that! I haven’t worked much with the code section of Wix, so are you able to point me in the direction of where I would put that code?

---

<div class="post-metadata">

**Author:** ![jeromechauveau](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@jeromechauveau](https://forum.wixstudio.com/u/jeromechauveau)\
**Post date:** [July 23, 2018, 8:56pm UTC](https://forum.wixstudio.com/t/help-with-tallying-up-info-from-checkboxes/6483/4 "2018-07-23T20:56:23Z")

</div>

My pleasure.  
For front code, you put it in the code panel of your page. You’ll find relevant info here: [Velo: Working in the Code Panel | Help Center | Wix.com](https://support.wix.com/en/article/working-in-the-code-panel).  
Let me know if you need more help.

---

<div class="post-metadata">

**Author:** ![tgzegel](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@tgzegel](https://forum.wixstudio.com/u/tgzegel)\
**Post date:** [August 4, 2018, 3:27pm UTC](https://forum.wixstudio.com/t/help-with-tallying-up-info-from-checkboxes/6483/5 "2018-08-04T15:27:45Z")

</div>

Thank you so much! I was able to figure it out with your help!
