Skip to main content
Participating Frequently
December 16, 2018
Answered

visible/hidden text field dependant on 2 checkboxes

  • December 16, 2018
  • 1 reply
  • 1346 views

Hi.

I have the below scenario, whereby there are two checkbox options and if yes is selected for either of them, then they need to provide details in the text field, even if no is selected in one but yes is selected in the other I need the text field to be visible, but if no is selected for both then the text fields should be hidden

I currently have this script (or something similar) in all of the checkboxes:

// fields to show and hide
var field1 = this.getField("Specify any restrictions etc and/or failure to comply with restrictions etc 1");
var field2 = this.getField("Specify any restrictions etc and/or failure to comply with restrictions etc 2");


// check box that changes visibility
if (this.getField("Check Box49").value == "Yes")
{
//hide these fields
      field1.display = display.visible;
      field2.display = display.visible;
}

else
{
// show these fields
      field1.display = display.visible;
      field2.display = display.visible;
}

This works if they select no for the first option and yes for the second.  But, if they select yes for the first option and no for the second, it removes the text fields.

I'm just learning scripts in Adobe pro DC so I'd really appreciate any help I can get.

thanks

Leah

This topic has been closed for replies.
Correct answer try67

Hi!

I would do it using this code as the custom calculation script of the first text field:

var field1 = event.target;

var field2 = this.getField("Specify any restrictions etc and/or failure to comply with restrictions etc 2");

var showFields = (this.getField("Check Box49").valueAsString=="Yes" || this.getField("Check Box50").valueAsString=="Yes");

field1.display = (showFields ? display.visible : display.hidden);

field2.display = (showFields ? display.visible : display.hidden);

1 reply

try67
Community Expert
Community Expert
December 16, 2018

What are the names of both check-box groups?

leahc18Author
Participating Frequently
December 16, 2018

Hi try67

The first checkbox is called "Check Box49" and second one is called "Check Box50"

Thanks

Leah

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
December 16, 2018

Hi!

I would do it using this code as the custom calculation script of the first text field:

var field1 = event.target;

var field2 = this.getField("Specify any restrictions etc and/or failure to comply with restrictions etc 2");

var showFields = (this.getField("Check Box49").valueAsString=="Yes" || this.getField("Check Box50").valueAsString=="Yes");

field1.display = (showFields ? display.visible : display.hidden);

field2.display = (showFields ? display.visible : display.hidden);