Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Adobe Forms Javascript and Checkboxes

Explorer ,
Nov 30, 2022 Nov 30, 2022

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"

TOPICS
How to , JavaScript , PDF forms
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2022 Nov 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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 30, 2022 Nov 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2022 Nov 30, 2022
LATEST

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines