# Please Help!-? calculation error and Item array error? )-:

**URL:** <https://forum.wixstudio.com/t/please-help-calculation-error-and-item-array-error/30113>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [January 9, 2020, 6:39am UTC](https://forum.wixstudio.com/t/please-help-calculation-error-and-item-array-error/30113 "2020-01-09T06:39:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thegotocontractors](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/thegotocontractors/32/12548_2.png) [@thegotocontractors](https://forum.wixstudio.com/u/thegotocontractors)\
**Post date:** [January 9, 2020, 6:39am UTC](https://forum.wixstudio.com/t/please-help-calculation-error-and-item-array-error/30113/1 "2020-01-09T06:39:53Z")

</div>

I’m trying to have a checkbox calculator where if someone selects the checkbox with 20 and 40 the total text should equal “60” not “20 40”

please help I don’t know what’s wrong with my code it seems like everything is perfectly correct.

what does item array mean it just keeps popping up?

 ![](https://us1.discourse-cdn.com/wix/original/3X/d/2/d22dd4ce7eacfb838914b7b60e6b9c329abab239.png)

import wixLocation **from** ‘wix-location’;  
$w.onReady( **function** () {  
**let** SFI = Number($w(“#input1”).value);  
$w(‘#checkboxGroup1’).value = “0”;  
$w(‘#checkboxGroup2’).value = “0”;  
$w(“#checkboxGroup3”).value = “0”;  
$w(“#checkboxGroup4”).value = “0”;  
});  
**function** radioGroup1() {  
**let** SFI = Number($w(“#input1”).value);  
**if** ($w(“#checkboxGroup1”).value === “0”) {  
$w(“#checkboxGroup1”).value = (SFI_20).toFixed(1).toString();  
}  
 **else** {  
$w(“#checkboxGroup1”).value = “0”;  
}}  
 **function** radioGroup2() {  
 **let** SFI = Number($w(“#input1”).value);  
 **if** ($w(“#checkboxGroup2”).value === “0”) {  
$w(“#checkboxGroup2”).value = (SFI_40).toFixed(1).toString();  
}  
**else** {  
$w(“#checkboxGroup2”).value = “0”;  
}}  
**function** radioGroup3() {  
**let** SFI = Number($w(“#input1”).value);  
**if** ($w(“#checkboxGroup3”).value === “0”) {  
$w(“#checkboxGroup3”).value = (SFI_55_1).toFixed(1).toString();  
}  
**else** {  
$w(“#checkboxGroup3”).value = “0”;  
}}  
**function** radioGroup4() {  
**let** SFI = Number($w(“#input1”).value);  
**if** ($w(“#checkboxGroup4”).value === “0”) {  
$w(“#checkboxGroup4”).value = (SFI_85_1).toFixed(1).toString();  
}  
**else** {  
$w(“#checkboxGroup4”).value = “0”;  
}}  
**function** valueCombine() {  
**let** checkedValue = $w(“#checkboxGroup1”).value + " " + $w(“#checkboxGroup2”).value

- " " + $w(“#checkboxGroup3”).value + " " + $w(“#checkboxGroup4”).value;  
$w(“#TotalPrice”).text = checkedValue;  
}  
export function submitButton\_mouseIn() {  
valueCombine();  
}

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [January 9, 2020, 8:36am UTC](https://forum.wixstudio.com/t/please-help-calculation-error-and-item-array-error/30113/2 "2020-01-09T08:36:32Z")

</div>

You are “adding” (concatenating) strings, therefore what you get is one big long string put together from the all of the component strings.

What you want to do is to convert the string values to numbers in order to add. Something like this:

```javascript
Number(numberString);

```

You are getting the errors since the value property of the CheckBoxGroup is an array, not a string.

---

<div class="post-metadata">

**Author:** ![thegotocontractors](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/thegotocontractors/32/12548_2.png) [@thegotocontractors](https://forum.wixstudio.com/u/thegotocontractors)\
**Post date:** [January 15, 2020, 1:24am UTC](https://forum.wixstudio.com/t/please-help-calculation-error-and-item-array-error/30113/3 "2020-01-15T01:24:45Z")

</div>

can you please send me an example code i’ve been trying for three weeks and i’ve gotten no results. my brain is completely fried. cant figure out how to add checkbox values together on one string \* user input “square footage”

---

<div class="post-metadata">

**Author:** ![givemeawhisky](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/givemeawhisky/32/5383_2.png) [@givemeawhisky](https://forum.wixstudio.com/u/givemeawhisky)\
**Post date:** [January 15, 2020, 12:25pm UTC](https://forum.wixstudio.com/t/please-help-calculation-error-and-item-array-error/30113/4 "2020-01-15T12:25:37Z")

</div>

Further to Yisrael’s post above, you have posted multiple posts all about the same or very similar question, which you have used different elements of checkboxes and checkbox groups.

So note that checkbox and checkbox groups are different and have different code for each of them.

Checkboxes you can get the individual value.  
[https://www.wix.com/corvid/reference/$w.Checkbox.html](https://www.wix.com/corvid/reference/$w.Checkbox.html)  
[https://www.wix.com/corvid/reference/$w.Checkbox.html#value](https://www.wix.com/corvid/reference/$w.Checkbox.html#value)

Whereas checkbox groups the values are saved in an array  
[https://www.wix.com/corvid/reference/$w.CheckboxGroup.html](https://www.wix.com/corvid/reference/$w.CheckboxGroup.html)  
[https://www.wix.com/corvid/reference/$w.CheckboxGroup.html#value](https://www.wix.com/corvid/reference/$w.CheckboxGroup.html#value)

The same as if you set the options for the checkbox group too, it is all in an array.  
[https://www.wix.com/corvid/reference/$w.CheckboxGroup.html#options](https://www.wix.com/corvid/reference/$w.CheckboxGroup.html#options)

if you want to add values together in an array you can look at using sum or reduce, which might sound wrong to you, however it does the job!  
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/Array/Reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)  
[https://www.w3schools.com/jsref/jsref\_reduce.asp](https://www.w3schools.com/jsref/jsref_reduce.asp)  
[https://codeburst.io/javascript-arrays-finding-the-minimum-maximum-sum-average-values-f02f1b0ce332](https://codeburst.io/javascript-arrays-finding-the-minimum-maximum-sum-average-values-f02f1b0ce332)  
[https://www.w3resource.com/javascript-exercises/javascript-math-exercise-17.php](https://www.w3resource.com/javascript-exercises/javascript-math-exercise-17.php)  
[https://medium.com/@chrisburgin95/rewriting-javascript-sum-an-array-dbf838996ed0](https://medium.com/@chrisburgin95/rewriting-javascript-sum-an-array-dbf838996ed0)

In this post above and in this post linked below you are using checkbox group and hence why you are getting the array message when you are trying to write code as if you are using checkboxes only.  
[https://www.wix.com/corvid/forum/community-discussion/sdk-error-item-is-not-of-array-please-help](https://www.wix.com/corvid/forum/community-discussion/sdk-error-item-is-not-of-array-please-help)

Whereas in this post, you write the code as if you are using checkboxes which is right,  
[https://www.wix.com/corvid/forum/community-discussion/sdk-error](https://www.wix.com/corvid/forum/community-discussion/sdk-error)

Therefore as you have posted multiple posts about the same thing two posts will be closed and the only one left open will be the one where you have used checkboxes and checkbox code and not checkbox groups with code for checkboxes.
