Copy link to clipboard
Copied
Hi,
I have a list of items and each item has a point value that is summed up in a "Total" calculation.
Is there a way that I can deactivate one or more items from beeing counted? Perfect would be a checkbox for each item, that I could click and the item would not be counted - without having to delete the item.
And if I uncheck the checkbox it would be counted again?
Tim
Yes, that is possible, using a script. You would need to iterate over the check-boxes and if they are ticked then you add the value of the corresponding text field to the total, and apply the total to the calculating field at the end of the process.
This is not too complicated, provided the names of the check-boxes and text fields are matching and consistent.
For example, if they are called CB1, Text1, CB2, Text2, etc. then you can use this code as the custom calculation script of the total fiel
...Copy link to clipboard
Copied
Yes, that is possible, using a script. You would need to iterate over the check-boxes and if they are ticked then you add the value of the corresponding text field to the total, and apply the total to the calculating field at the end of the process.
This is not too complicated, provided the names of the check-boxes and text fields are matching and consistent.
For example, if they are called CB1, Text1, CB2, Text2, etc. then you can use this code as the custom calculation script of the total field to do it (let's assume there are 20 such sets of fields):
var total = 0;
for (var i=1; i<=20; i++) {
if (this.getField("CB"+i).valueAsString!="Off") total+=Number(this.getField("Text"+i).valueAsString);
}
event.value = total;
Copy link to clipboard
Copied
That sounds very promising.
Is it possible to handle it the other way around?
So the values are not counted when the checkbox is ticked?
Would I have to set valueAsString!= to "On" ?
Copy link to clipboard
Copied
You have the correct idea, but the default On value (i.e. export value) for a checkbox is "Yes".
However, the best strategy is to change the comparsion condition to
valueAsString == "Off"
The reason for this is that "Off" is always the Off value for a checkbox. So this code will work, regardless of the actual export value from the checkbox.
Copy link to clipboard
Copied
ok - I understand.
Once more - thank you very much for your support!
Tim