Copy link to clipboard
Copied
Hi!
I'm trying to have a sum range trigger the showing of a check mark on a field.
For example if sum total is 19 a check mark will show up in box 1 because it is below 20.
If sum total is 28 a check mark will show up in box 3 becasue it is between 25-30.
I'm a novice at Adobe and your help is greatly appreciated!
Copy link to clipboard
Copied
Enter the following custom calculation script in the Sum field and change the field names to match your check boxes:
event.value<20?this.getField("Check Box1").checkThisBox(0,true):this.getField("Check Box1").checkThisBox(0,false);
(event.value>19 && event.value<25)?this.getField("Check Box2").checkThisBox(0,true):this.getField("Check Box2").checkThisBox(0,false);
(event.value>24 && event.value<31)?this.getField("Check Box3").checkThisBox(0,true):this.getField("Check Box3").checkThisBox(0,false);
(event.value>40 && event.value<46)?this.getField("Check Box4").checkThisBox(0,true):this.getField("Check Box4").checkThisBox(0,false);
event.value>45?this.getField("Check Box5").checkThisBox(0,true):this.getField("Check Box5").checkThisBox(0,false);
Copy link to clipboard
Copied
Enter the following custom calculation script in the Sum field and change the field names to match your check boxes:
event.value<20?this.getField("Check Box1").checkThisBox(0,true):this.getField("Check Box1").checkThisBox(0,false);
(event.value>19 && event.value<25)?this.getField("Check Box2").checkThisBox(0,true):this.getField("Check Box2").checkThisBox(0,false);
(event.value>24 && event.value<31)?this.getField("Check Box3").checkThisBox(0,true):this.getField("Check Box3").checkThisBox(0,false);
(event.value>40 && event.value<46)?this.getField("Check Box4").checkThisBox(0,true):this.getField("Check Box4").checkThisBox(0,false);
event.value>45?this.getField("Check Box5").checkThisBox(0,true):this.getField("Check Box5").checkThisBox(0,false);
Copy link to clipboard
Copied
Oh Whoa! Thank you!
When I run the above provided formula, it now removes the sum value (first option provided by the system) that was selected.
Is there a way to have both options? Sum and Custom?
Copy link to clipboard
Copied
No, you can't have both options, but you can add the calculation to your current script, add this to custom calculation script (above your script):
var total = 0;
for(var i=10; i<=15; i++){
var f = this.getField(""+i).valueAsString;
if (f !== "" && !isNaN(Number(f)))
total+=Number(f);}
event.value = total;
Copy link to clipboard
Copied
Thank you!
I added the calculation above the script, which works, but now the check boxes don't work.
Is there something I'm missing?
Copy link to clipboard
Copied
does adding symbols in the field name mess with the formulation? Should I re-name (image below) the field names?
These are the names of the 5 check boxes
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Can you upload the form?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
There's an error in this line of my script:
event.value>40 && event.value<46
The 40 should be 30. Also, your checkboxes are hidden so you won't see the results unless you unhide them.
Copy link to clipboard
Copied
That correction worked! YIPPIE!
Is there a way to have all the boxes hidden except for the one corresponding to the total?
Copy link to clipboard
Copied
Yes, but it you don't want users to be able to interact with the check boxes, but still see the results, I would suggest setting the readonly property to true by selecting the Read Only boxes in the General tab of the check box properties.
Copy link to clipboard
Copied
Calculations run every time a field value changes, so this calculation will run every time you check one of the boxes. When the calculation runs, it will check and uncheck boxes according to the calculation. If you want the check boxes to override the calculation you will have to move the script I provided to another calculation field and put some conditions on the calculation (thanks to @Nesa Nurani for this):
https://pdfautomationstation.substack.com/p/another-method-for-calculation-vs
Copy link to clipboard
Copied
I didn't know it already had a calculation. You can leave your calculation and move my script above to the custom calculation for another field, but change all of the event words to this.getField("Sum") [or whatever the name of your Sum field is]. Make sure this field calculates after the Sum field in the calculation order.
Copy link to clipboard
Copied
insightful read on the calculation order! Thank you for sharing!
I tried to subscribe to the newsletter (admin@ridgewealth.com), however the page gives a error code.
Copy link to clipboard
Copied
Thank you. What is the error code?
Copy link to clipboard
Copied
something went wrong.
Copy link to clipboard
Copied
I'll subscribe you.
Copy link to clipboard
Copied
Thank you! 😄