Adobe Forms Javascript and Checkboxes
Copy link to clipboard
Copied
Hi everyone, trying to figure out the following. I have a series of checkboxes that are used to either show, hide or move other checkboxes and fields. That is working fine. I have discribed below in english of what I would like to achieve and have included a screenshot for reference. Thanks very much in advance.
By choosing "Checkbox 1" OR "Checkbox 2" OR "Checkbox 3 AND "Checkbox 4" "Checkbox 5" =true
Meaning "Checkbox 5" is "checked"
Copy link to clipboard
Copied
A calculation script would work best since several inputs are required to set "Checkbox5". Place the calculation script on any text field that isn't being used for anything else.
var bOn = (this.getField("Checkbox 1").value != "Off") || (this.getField("Checkbox 2").value != "Off") || (this.getField("Checkbox 3").value != "Off") && (this.getField("Checkbox 4").value != "Off");
this.getField("Checkbox 5").value = bOn?"Yes":"Off";
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Thanks so much Thom. It works great. One last question if you don't mind. If I deselct anyone of the first four checkboxes I would like Checkbox 5 to uncheck. Hope that makes sense.
Copy link to clipboard
Copied
You just need to add that condition to calculation of "bOn".
The process for working out logic is to write out all of the possible conditions in a table. Then write a logic statement that satisfies the conditions.
Use the Acrobat JavaScript Reference early and often

