Copy link to clipboard
Copied
Hi, I'm new to this. I have a group of 3 checkboxes ("High","Medium", and "Low") that I want checked based on the value that is calculated in another field "Total".
If total is >= 40 then High checkbox is activated with the others off.
If total is between 30 to 35 then Medium checkbox is activated with the others off.
If total is <=25 then Low checkbox is activated and the others off.
I appreciate any help with this.
Thanks.
Do you use a calculation script for the total field? or one of the other calculation options?
If the calculation is done with a script, then youc an add the code for setting the checkbox to the end of it. Otherwise you can make this a Validation Script on the Total field.
To setup the checkboxes, they all need to have the same name ("Level" for example), so that they are all part of the same group. Each needs to have a different export value, "High", "Medium", and "Low".
Whether it's the
...Copy link to clipboard
Copied
Do you use a calculation script for the total field? or one of the other calculation options?
If the calculation is done with a script, then youc an add the code for setting the checkbox to the end of it. Otherwise you can make this a Validation Script on the Total field.
To setup the checkboxes, they all need to have the same name ("Level" for example), so that they are all part of the same group. Each needs to have a different export value, "High", "Medium", and "Low".
Whether it's the calculation or validation scirpt, the code is the same.
if(event.value >= 40) this.getFeld("Level").value = "High";
else if (event.value >= 30) this.getFeld("Level").value = "Medium";
else this.getFeld("Level").value = "Low";
Note that the mid level is 30 to 40, and the low is < 30. The ranges you've specified are incomplete.
Copy link to clipboard
Copied
Thank you that worked. A follow up if I may.
I used your script as a validation script for the "Total" field.
If Level "High" "Medium" or "Low is checked and another checkbox is checked, for now let's call it Checkbox1, I would like a value to populate in a separate text field. For example, if "High" and "Checkbox1" are checked then the value in the new text field = 4.
Also, would this script be placed in the custom format script of the new text field?
Thanks again.
Copy link to clipboard
Copied
For this type of behavior you need a to use a calculation script in the new field. Calculation scripts are run any time any field value is changed. The required values are coming from multiple sources. The script for setting the value in the new field has to be triggered (run) on changes in the source fields. A calculation script is perfect for this.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
So you can read about the type of calculation you need here:
https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations/
https://acrobatusers.com/tutorials/conditional-execution/
Here's what your code should look like
var cLevel = this.getFeld("Level").value;
if( this.getFeld("Checkbox1").value != "Off")
{// Checked case
if(cLevel == "High")
event.value = 4;
else if(cLevel == "Medium")
event.value = ... something...;
}
else
{// Unchecked case
}