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

Checkbox conditions based on another checkbox

New Here ,
Feb 26, 2023 Feb 26, 2023

Copy link to clipboard

Copied

Im fairly new to this and need assistance.  I have a set of checkbox that need to meet certain conditions.  Here are the conditions.  I have two columns of checkboxes.  Column one has checkbox 1, 2 and 3 and column two has 4, 5, and 6.  If checkbox 1 is checked then checkbox 3 is checked automatically.  If checkbox 2 is checked then checkbox 3 is checked automatically.  If checkbox 4 is checked then checkbox 6 is checked automatically and if checkbox 5 is checked then checkbox 6 is automatically checked.  Here is the other part that i need assistance with.  If checkbox 1 is checked then checkbox 4 is disabled and checkbox 3 is checked automatically.  If checkbox 2 is also checked then checkbox 5 is disabled and checkbox 3 is still checked, but if checkbox 5 is checked then checkbox 2 is disabled and checkbox 4 is unchecked. 

TOPICS
How to , JavaScript

Views

4.3K

Translate

Translate

Report

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 ,
Feb 26, 2023 Feb 26, 2023

Copy link to clipboard

Copied

See if this works for you, use it in a text field as custom calculation script:

var c1 = this.getField("checkbox 1");
var c2 = this.getField("checkbox 2");
var c3 = this.getField("checkbox 3");
var c4 = this.getField("checkbox 4");
var c5 = this.getField("checkbox 5");
var c6 = this.getField("checkbox 6");


if(c1.isBoxChecked(0,true)){
c3.checkThisBox(0,true);
c4.readonly = true;}
else
c4.readonly = false;

if(c2.isBoxChecked(0,true)){
c3.checkThisBox(0,true);
c5.readonly = true;}
else
c5.readonly = false;

if(c4.isBoxChecked(0,true))c6.checkThisBox(0,true);

if(c5.isBoxChecked(0,true)){
c6.checkThisBox(0,true);
c2.readonly = true;
c4.checkThisBox(0,false);}
else
c2.readonly = false;

Votes

Translate

Translate

Report

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
New Here ,
Feb 27, 2023 Feb 27, 2023

Copy link to clipboard

Copied

Thank you for your response.  what you provided did work but not the way I need it to work.  When c1 is checked, c3 is checked which is good.  but when i uncheck c1, c3 is still checked.  i need it to uncheck automatically.  Here is what would like for this to work.

 

Yes Column

If c1 is checked then c3 is checked automatically and c4 is disabled

If c2 is checked then c3 is checked automatically and c5 is disabled

c3 should not be a checkable, possibly be a readonly box that is checked on when c1 or c2 is checked

same thing should happen for No column

Here is the twist.  If c4 is checked and of course c6 is checked. if c2 is checked then c6 needs to be unchecked automatically.  and of course since c2 is checked c3 will be checked automatically.  Basically if there are any check marks in the Yes column then the No column c6 is automatically unchecked.  i hope this makes sense.

Votes

Translate

Translate

Report

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 ,
Feb 28, 2023 Feb 28, 2023

Copy link to clipboard

Copied

Try this:

var c1 = this.getField("checkbox 1");
var c2 = this.getField("checkbox 2");
var c3 = this.getField("checkbox 3");
var c4 = this.getField("checkbox 4");
var c5 = this.getField("checkbox 5");
var c6 = this.getField("checkbox 6");


c3.checkThisBox(0,(c1.valueAsString != "Off" || c2.valueAsString != "Off"));
if(c1.valueAsString != "Off"){
c4.value = "Off";
c4.readonly = true;}
else
c4.readonly = false;
if(c2.valueAsString != "Off"){
c5.value = "Off";
c5.readonly = true;}
else
c5.readonly = false;
c6.checkThisBox(0,c3.valueAsString == "Off" && (c4.valueAsString != "Off" || c5.valueAsString != "Off"));

Votes

Translate

Translate

Report

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
New Here ,
Feb 28, 2023 Feb 28, 2023

Copy link to clipboard

Copied

What you provided worked.  But I need one thing to troubleshoot. As stated before on the Yes column when c1 is checked c5 is automatically checked.  On the No column when c6 is checked then c10 is automatically checked also.  Here is how it is setup now.  If question 1 answer is yes (c1) then c6 is automatically checked.  If question 2 answer is no (c7) then c10 is automatically checked. Now there c5 and c10 both have check marks.  If question 3 answers is yes (c3) then c10 is automatically unchecked. But if the final question 4 the answer is no (c8) then c10 is checked. so now i have both c5 and c10 with checkmarks.   I need to figure out a way that if any questions are answered yes, that the final (c5) is alway the only box that is checked.  You can still have an answer in the No column but c5 should always override any checkbox.  If there are any questions answered in the yes column, then c10 should not have a check mark.  Only time c10 should be checked is if all answers are NO.  i hope you can see the pdf i uploaded.  How about a script that says c10 is checked only when all c6, c7, c8 and c9 are marked.  I hope this makes sense.

Votes

Translate

Translate

Report

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
New Here ,
Feb 29, 2024 Feb 29, 2024

Copy link to clipboard

Copied

box1
if(this.getField("Box1").valueAsString!="On"){this.getField("Box2").value="Off";}

 

box2
if(this.getField("Box2").valueAsString!="On"){this.getField("Box1").value="Off";}

Votes

Translate

Translate

Report

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 ,
Feb 29, 2024 Feb 29, 2024

Copy link to clipboard

Copied

The state of the checkbox when checked is not 'On' unless you set its export value to be 'On'.

Are you are trying to create mutually exclusive checkboxes? There is an easier solution to do so:

Give both checkboxes same name but different export value.

Votes

Translate

Translate

Report

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
New Here ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

I have a similar situation. I need to auto answer C4 (YES) when all conditions are meet on C 1-3 (YES) and any other answer C9 should answer "NO" Can you help me with a script? 

Votes

Translate

Translate

Report

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 ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

Are those mutually exclusive checkboxes or single?

Is 'YES' export value of those checkboxes?

Can you share the file?

Votes

Translate

Translate

Report

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
New Here ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

Correct they are manually enter checkboxes. Yes, "YES" is the expeort value of those boxes (C1-3) and "NO" to (C6-8). I need to Check Box 4 answer "yes" when CB (1-3) are "YES". Any other answer check box should be check "NO", I added a screen shot. 

Votes

Translate

Translate

Report

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 ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

So Check Box5 is a "NO" which should be checked if any of the checkboxes are checked except for scenario of C1-3 are "YES"?

You should have make checkboxes mutually exclusive, so only one can be checked from YES/NO. For example change Check Box6 name to Check Box1, Check Box7 to Check Box2, Check Box8 to Check Box3, and Check Box5 to Check Box4, now only one at a time can be checked, and it will simplify script also.

Votes

Translate

Translate

Report

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
New Here ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

Nesa, I don't have any experience doing this type of work. Can you help me with that? 

Votes

Translate

Translate

Report

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
New Here ,
May 17, 2024 May 17, 2024

Copy link to clipboard

Copied

Aloha from Hawaii.  I'm learning about acrobat and have several applications for which acrobat is perfect for.  I have a somewhat similar question.  However, my requirement is that once All checkboxes are checked a final checkbox automatically becomes checked indicating the completion of the assigned task.  Is this something that can be done in Javascript?  If so, I really don't know javascript how would this be executed?  The current project I'm working on has seven (7) training requirements and when each is completed they check a box.  As a show of completion there is a "Completed" checkbox which I would like to automatically be select once All other requirements are met.

Votes

Translate

Translate

Report

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 ,
May 17, 2024 May 17, 2024

Copy link to clipboard

Copied

LATEST

Can you share the file or tell us the name of the checkboxes?

Votes

Translate

Translate

Report

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