Copy link to clipboard
Copied
Hello!
I have YES and NO checkboxes that need to uncheck based on other checkboxes. Basically,
A) Do the following actions occur? Yes No
1) action a Yes No
2) action b Yes No
3) action c Yes No
If all of the actions are YES, then A) should be YES, but if any are NO then A) should be NO.
Any ideas?
Thanks in advance!
Copy link to clipboard
Copied
To do this, a Calculation script is required, so add a hidden text field.
Next, to write the actual script the field names must be known. Let just say 1), 2), and 3) are "Action1' thru 'Action3', and A) is "QuestionA".
The export value for QuestionA must also be known. I'll assume it is the default value of "Yes".
Here's the calculation script
var bAllOn = (this.getField("Action1").value != "Off") && (this.getField("Action2").value != "Off") && (this.getField("Action3").value != "Off") ;
this.getField("QuestionA").value = bAllOn?"Yes":"Off";
Copy link to clipboard
Copied
Thank you! That worked to turn on the box for question A. I think I need to get more detailed...
Each of the questions have these possible answers: Yes, No, and N/A (see attached).
I'd like to automatically have Question A select between the three choices based on the answers to Actions 1, 2, & 3.
- If they are all Yes (or a combination of Yes and N/A), then QA should be Yes as well. However, if any of the Actions are No, then QA should be No.
Thanks so much for your help!
Copy link to clipboard
Copied
The solution can be generalized to accomodate any group of checkboxes with this configuration. To do this the fields need to be named in such a way that all related fields can be found. It looks like you have a naming scheme that will work for this. Although I would suggest the names are made more specific so they can be uniquely identified using a regular expression.
For example "Checks.1d2-1", etc.
var rgCheckQ = /Checks\.(\d\w\d)\-\d/
if(event.source && (rgCheckQ.test(event.source.name))
{
var cFldBase = "Check." + RegExp.$1;
var bAllOn = (this.getField(cFldBase + "-1").value != "Off") && (this.getField(cFldBase + "-2").value != "Off") && (this.getField(cFldBase + "-3").value != "Off") ;
this.getField(cFldBase).value = bAllOn?"Yes":"Off";
}
Copy link to clipboard
Copied
Well, I'm lost! When I replaced the previous script with this one, it doesn't seem to do anything. My level of experience with this is about 0.
Copy link to clipboard
Copied
The script is based off of the specific naming scheme presented in the post. So either the regular expression needs to be changed to accomdate the current naming scheme, or the form fields need to be renamed to match the regular expression.
The idea is to extract the common naming element from the checkbox that triggered the calculation script, and then use this common element to create the names of the related fields. The field that triggers a calculation is provided by the "event.source" property.
I've adjusted the script to use the naming scheme displayed in the screen shots in your post, i.e., "1d2-1", etc.
var rgCheckQ = /(\d\w\d)\-\d/
if(event.source && (rgCheckQ.test(event.source.name))
{
var cFldBase = RegExp.$1;
var bAllOn = (this.getField(cFldBase + "-1").value != "Off") && (this.getField(cFldBase + "-2").value != "Off") && (this.getField(cFldBase + "-3").value != "Off") ;
this.getField(cFldBase).value = bAllOn?"Yes":"Off";
}
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more