Skip to main content
Known Participant
November 30, 2022
Question

Adobe Forms Javascript and Checkboxes

  • November 30, 2022
  • 1 reply
  • 1663 views

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"

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
November 30, 2022

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";

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
November 30, 2022

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.

Thom Parker
Community Expert
Community Expert
November 30, 2022

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.  

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often