Copy link to clipboard
Copied
Ok so the problem I'm having building a PDF where I have to use checked checkboxes to determine a specific total amount that is entered into a different field. The issue is that there's no way to calculate the amounts with the checkbox value alone because the math doesn't split evenly. The price is based on a step up of $50 for each additional box that's checked. Is there a way to show a specific total/text based on how many of the checkboxes is checked? Or is there an efficient way to give the 1st checked box and value and then add the additional $50 for each additional box checked?
I need a script that shows a total based on three different scenarios:
any 1 of 3 boxes checked = $375
any 2 of 3 boxes checked = $425
any 3 of 3 boxes checked = $475
Normally I can tailor scripts to suit my needs, but this one has me stumped because I'm not even sure how to phrase my search.
Please help!
You can use this code as the custom calculation script of your field:
var fields = ["Checkbox-AL", "Checkbox-MS", "Checkbox-LA"];
var total = 0;
for (var i in fields) {
var f = this.getField(fields);
if (f.valueAsString!="Off") total++;
}
if (total==0) event.value = 0;
else event.value = 325 + (50 * total);
Copy link to clipboard
Copied
Yes, that's possible. What are the field names of the three check boxes?
Copy link to clipboard
Copied
Currently
Checkbox-AL
Checkbox-MS
Checkbox-LA
Copy link to clipboard
Copied
You can use this code as the custom calculation script of your field:
var fields = ["Checkbox-AL", "Checkbox-MS", "Checkbox-LA"];
var total = 0;
for (var i in fields) {
var f = this.getField(fields);
if (f.valueAsString!="Off") total++;
}
if (total==0) event.value = 0;
else event.value = 325 + (50 * total);
Copy link to clipboard
Copied
Works like a charm! Thank you very much! try67
Also thank you George_Johnson! This is the first time we've interacted, but I've read lots of your posts and they've all be super helpful!