visible/hidden text field dependant on 2 checkboxes

Community Beginner ,
Dec 16, 2018 Dec 16, 2018

Copy link to clipboard

Copied

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

TOPICS
Acrobat SDK and JavaScript, Windows

Views

262

Likes

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

correct answers 1 Correct Answer

Most Valuable Participant , Dec 16, 2018 Dec 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);

Likes

Translate

Translate
Most Valuable Participant ,
Dec 16, 2018 Dec 16, 2018

Copy link to clipboard

Copied

What are the names of both check-box groups?

Likes

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 Beginner ,
Dec 16, 2018 Dec 16, 2018

Copy link to clipboard

Copied

Hi try67

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

Thanks

Leah

Likes

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
Most Valuable Participant ,
Dec 16, 2018 Dec 16, 2018

Copy link to clipboard

Copied

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);

Likes

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 Beginner ,
Dec 16, 2018 Dec 16, 2018

Copy link to clipboard

Copied

thank you so much try67

just to confirm, does that go into the custom format script or custom keystroke script (or both) or somewhere else.

I have tried it in both script fields and it is hiding the text fields straight away instead of when clicking on the checkboxes.

thanks

Leah

Likes

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
Most Valuable Participant ,
Dec 17, 2018 Dec 17, 2018

Copy link to clipboard

Copied

Neither. It's a custom calculation script, as I wrote.

Likes

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 Beginner ,
Dec 17, 2018 Dec 17, 2018

Copy link to clipboard

Copied

LATEST

thank you try67

As I wrote, I'm very new to this.  I have googled it and found how to do a calculation script

thank you for your assistance

Likes

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