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://static.wixstatic.com/media/a27d24_518a7f0a9f064045abf6e253098ebfdc~mv2.png/v1/fill/w_980,h_611,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/a27d24_518a7f0a9f064045abf6e253098ebfdc~mv2.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();
}
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#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#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
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://www.w3schools.com/jsref/jsref_reduce.asp
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://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
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
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.
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:
Number(numberString);
You are getting the errors since the value property of the CheckBoxGroup is an array, not a string.