Count checkbox

I have a dataset with 50 checkbox, and I want put a progress bar, to show how close they are to the end.

https://www.wix.com/corvid/reference/$w.ProgressBar.html

I already read that. There I saw “How many tasks are marked as done on a to-do list.”, but isnt a link, i dont know where I find that.

In my study I finded this “count += 1”, but I have no idea how use.

It should work like this:
At each stage you summarize how many you have arrived, how many are marked, and then define it by the number.

If you were to explain more about what a data set means, what do you have in this form with 50 questions? Or 50 rows in the table? I might have been able to help more

Are 50 different little books they need ready. Every time when they finish a book they mark a box, and the bar will show the progress. Are 50 columns

Do you keep their markup in a database?
Does one page show all 50 books? How to use a repiter? (Maybe squeezing a screenshot will be easier)
What input tool do you use to mark?

sorry for my ignorance, but does the method I use to check boxes matter? I just want to know how to count how many boxes are checked.

Every profile have 1 row with 50 columns, and I can put a new columns with total of this count if we need.

If it is not connected to a database it works that way

$ w (“# progressBar1”). targetValue = 50;

export function checkbox3_change (event) {
if ($ w (“# checkbox3”). checked === true) {
$ w (“# progressBar1”). value = $ w (“# progressBar1”). value + 1
} else {
$ w (“# progressBar1”). value = $ w (“# progressBar1”). value - 1
}

And if every markup you keep in the database, then after every markup you have to check how many are marked then that number set here

If you know how to save in a database, you probably know how to bring and summarize

$w("#progressBar1").value = count

Thanks, I will try this

Just to let you know, it worked. Thank you very much.

Now I took advantage of the learning in this question to incorporate my website, and I have a new problem. Can you help me?

When I launch this code, it is not adding 1 to 1, but taking only the last +1 . The idea is that it is like correcting a test.


    if ($w('#dataset1').getCurrentItem().ask1 === $w('#dataset2').getCurrentItem().ask1) {
        $w('#dataset2').setFieldValue("automatic", +1)
}
    if ($w('#dataset1').getCurrentItem().ask2 === $w('#dataset2').getCurrentItem().ask2) {
        $w('#dataset2').setFieldValue("automatic", +1)
}
    if ($w('#dataset1').getCurrentItem().ask3 === $w('#dataset2').getCurrentItem().ask3) {
        $w('#dataset2').setFieldValue("automatic", +1)
}
    if ($w('#dataset1').getCurrentItem().ask4 === $w('#dataset2').getCurrentItem().ask4) {
        $w('#dataset2').setFieldValue("automatic", +1)
}


@samuel-milanez

When you want to add a number, you need to add. Set the automatic value to be equal to the previous value plus 1, in what you did you told him to update the value to +1 without adding the 1 to the existing value.

By the way for not asking for many times, I set the value to a variable.
Give it a try:

let ask1 = $w(‘#dataset2’).getCurrentItem().ask1,
ask2 = $w(‘#dataset2’).getCurrentItem().ask2,
ask3 = $w(‘#dataset2’).getCurrentItem().ask3,
ask4 = $w(‘#dataset2’).getCurrentItem().ask4;
if ($w(‘#dataset1’).getCurrentItem().ask1 ===ask1) {
$w(‘#dataset2’).setFieldValue(“automatic”,ask1 +1)
}
if ($w(‘#dataset1’).getCurrentItem().ask2 === ask2) {
$w(‘#dataset2’).setFieldValue(“automatic”, ask2+1)
}
if ($w(‘#dataset1’).getCurrentItem().ask3 === ask3) {
$w(‘#dataset2’).setFieldValue(“automatic”,ask3 +1)
}
if ($w(‘#dataset1’).getCurrentItem().ask4 === ask4) {
$w(‘#dataset2’).setFieldValue(“automatic”, ask4 +1)
}

happily
evyatar. israel

You may need to convert the string to a number for you to do calculations with it. So it should be like this:

let ask1 = Number($w(‘#dataset2’).getCurrentItem().ask1),
ask2 = Number($w(‘#dataset2’).getCurrentItem().ask2),
ask3 = Number($w(‘#dataset2’).getCurrentItem().ask3),
ask4 = Number($w(‘#dataset2’).getCurrentItem().ask4);
if ($w(‘#dataset1’).getCurrentItem().ask1 ===ask1) {
$w(‘#dataset2’).setFieldValue(“automatic”,ask1 +1)
}
if ($w(‘#dataset1’).getCurrentItem().ask2 === ask2) {
$w(‘#dataset2’).setFieldValue(“automatic”, ask2+1)
}
if ($w(‘#dataset1’).getCurrentItem().ask3 === ask3) {
$w(‘#dataset2’).setFieldValue(“automatic”,ask3 +1)
}
if ($w(‘#dataset1’).getCurrentItem().ask4 === ask4) {
$w(‘#dataset2’).setFieldValue(“automatic”, ask4 +1)
}

@av-promotional Thanks again worked.