Skip to main content
Participant
November 19, 2021
Answered

Hide/show checkbox based on another checkbox

  • November 19, 2021
  • 2 replies
  • 5580 views

Hi,

I am very new to Adobe, and currently creating a fillable form for intern work.

 

Is there a way to hide/show a checkbox based on whether or not another checkbox is checked/unchecked?

 

I want "box2" to show only if "box1" is checked. If "box1" is unchecked, "box2" should be hidden.

 

I've been looking around the forum and elsewhere, but can't really seem to find a solution. 

 

Additional info: "box1" is "pre-checked", so that when colleagues open the file, "box1" will already be checked (they're supposed to uncheck boxes themselves). So when they remove the check / uncheck "box1", "box2" will become hidden. 

This topic has been closed for replies.
Correct answer Nesa Nurani

You can use this code as Mouse UP event of CheckBox1:

this.getField("CheckBox2").display = event.target.value == "Off" ? display.hidden : display.visible;

2 replies

JR Boulay
Community Expert
Community Expert
November 22, 2021

Give the export value "Yes" to checkbox 1

Acrobate du PDF, InDesigner et Photoshopographe
Karl Heinz  Kremer
Community Expert
Community Expert
November 19, 2021

Let's say you have a checkbox named CheckBox1 and another one named CheckBox2, and you want to hide CheckBox2. The following script, when used as a "MouseUp" action for CheckBox1 will do this:

 

if (event.target.value == "Yes") {
    this.getField("CheckBox2").display = display.visible;
}
else {
    this.getField("CheckBox2").display = display.hidden;
}
enyl3Author
Participant
November 22, 2021

Hi Karl,

 

Thank you. This seems to "almost" do the job. When I uncheck "CheckBox1", "CheckBox2" becomes hidden (which is exactly what I wanted). But when I check "CheckBox1" again, "CheckBox2" remains hidden. Is there a way to make it so that "visibility" of "CheckBox2" constantly depends on whether or not "CheckBox1" is checked?

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
November 22, 2021

You can use this code as Mouse UP event of CheckBox1:

this.getField("CheckBox2").display = event.target.value == "Off" ? display.hidden : display.visible;