Skip to main content
Participant
February 15, 2024
Answered

How to make different group check boxes in PDF forms

  • February 15, 2024
  • 2 replies
  • 2844 views

Hi everyone,

 

In PDF Forms I am struggling with adding some checkboxes and I've included an example. 

I want people to only choose the option 'Yes' or 'No', so I gave the checkbox the same name with a different export value, but I want the checkbox 'Name' and 'Adress' only to be clickable when the checkbox for 'Yes' is checked, so that you cannot check the box for 'No' and check the box 'Adress' at the same time. 

Thanks!

This topic has been closed for replies.
Correct answer BarlaeDC

Hi,

 

I would recommend you change the Yes/No checkboxes to be a radio button group, as in this group only one field can have a value, so either the yes or no can only be clicked, if one is clicked it clears the value from the other one.

 

You can add a JavaScript on each of the radio buttons that shows/hides the other checkboxes, making so that they cannot be filled in if you radio buttons are not clicked correctly.

 

```

this.getField("Check Box2").display = display.visible;
this.getField("Check Box3").display = display.visible;

```

for when you want to be able to click the checkboxes and

```

this.getField("Check Box2").display = display.hidden;
this.getField("Check Box3").display = display.hidden;

```

Obviously you need to change the names of the fields.

 

Hope this helps

 

2 replies

BarlaeDC
Community Expert
BarlaeDCCommunity ExpertCorrect answer
Community Expert
February 15, 2024

Hi,

 

I would recommend you change the Yes/No checkboxes to be a radio button group, as in this group only one field can have a value, so either the yes or no can only be clicked, if one is clicked it clears the value from the other one.

 

You can add a JavaScript on each of the radio buttons that shows/hides the other checkboxes, making so that they cannot be filled in if you radio buttons are not clicked correctly.

 

```

this.getField("Check Box2").display = display.visible;
this.getField("Check Box3").display = display.visible;

```

for when you want to be able to click the checkboxes and

```

this.getField("Check Box2").display = display.hidden;
this.getField("Check Box3").display = display.hidden;

```

Obviously you need to change the names of the fields.

 

Hope this helps

 

Thom Parker
Community Expert
Community Expert
February 15, 2024

There are a couple of things that would create this effect. 

1. Add a script to the MouseUp of the Yes and No buttons that will set the readonly propertly of the address box.

2. Add a "Show/Hide a field" action to the MouseUp of the Yes and No buttons. 

 

The second option will work on more platforms because it doesn't use a script. #1 will only on PDF viewers that support scripting.   But neither will work in all cases. 

 

 

 

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