Skip to main content
Participant
July 22, 2023
Question

If only cb1 is checked then cb4 is checked too

  • July 22, 2023
  • 2 replies
  • 874 views

Hello,

 

I came across another issue....

 

I have 3 checkboxes (CB1, CB2 and CB3)

I like CB4 to be checked when only CB3 is checked.

If any of the other combinations are checked (when cb1 and cb3 are checked or cb2 and cb3) cb4 needs to be unchecked.

i try using other scrips i found but i cant find the right solution.

For all of you masters here, it would be a piece of cake i guess 😉

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
July 22, 2023

As the custom calculation script of a (hidden) text field enter the following code:

 

var CB1 = this.getField("CB1").valueAsString!="Off";
var CB2 = this.getField("CB2").valueAsString!="Off";
var CB3 = this.getField("CB3").valueAsString!="Off";

this.getField("CB4").checkThisBox(0, !CB1 && !CB2 && CB3);
Participant
July 22, 2023

It worked perfectly thnx.....

but i made one misstake.....

CB4 isnt a checkbox but a radiobutton called Group4 and its the 3rd choice.

 

What wil be different?

Thom Parker
Community Expert
Community Expert
July 23, 2023

Yes, that will be different. What's the export value for the 3rd Choice? 

You can read about how radiobuttons and checkboxes work in Acrobat here:

https://www.pdfscripting.com/public/Checkboxes-and-Radio-Buttons.cfm

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Thom Parker
Community Expert
Community Expert
July 22, 2023

Write out a table showing the state of the check boxes (forced checked, forced unchecked, and user controled) depending on what is checked. Cover all combinations. 

Use this to write scripts for the MouseUp event on each checkbox. 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
July 22, 2023

I dont know what you mean. im just learning....

the thing is, i only try to use scrips when there is no other way so its hard to put time in it to learn properly.

 

A start would be helpful 😉