How do I Show and Hide fields based on Yes or No radio buttons?

New Here ,
Nov 16, 2017

Copy link to clipboard

Copied

Trying to create a form, where if they check "Yes" or unchecking of "Yes" would also erase/hide the "A_Comments" box.

My issue is; if I uncheck "yes" the A_Comments field remains visible. Checking "No" does hide and blanks out any content.

Yes_No.jpg

I have the following code on the "Yes":

this.getField("A_Comments").display=display.visible;

and this on the "No":

this.getField("A_Comments").display=display.hidden

"A_Comments" field has the following text Field Properties:

Properties/General/Form Field: Hidden

Any help would be appreciated.

Regards,

Adobe Community Professional
Correct answer by Thom Parker | Adobe Community Professional

Read this article:

https://acrobatusers.com/tutorials/show_hide_fields

It has exactly what you need

TOPICS
Acrobat SDK and JavaScript, Windows

Views

978

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

How do I Show and Hide fields based on Yes or No radio buttons?

New Here ,
Nov 16, 2017

Copy link to clipboard

Copied

Trying to create a form, where if they check "Yes" or unchecking of "Yes" would also erase/hide the "A_Comments" box.

My issue is; if I uncheck "yes" the A_Comments field remains visible. Checking "No" does hide and blanks out any content.

Yes_No.jpg

I have the following code on the "Yes":

this.getField("A_Comments").display=display.visible;

and this on the "No":

this.getField("A_Comments").display=display.hidden

"A_Comments" field has the following text Field Properties:

Properties/General/Form Field: Hidden

Any help would be appreciated.

Regards,

Adobe Community Professional
Correct answer by Thom Parker | Adobe Community Professional

Read this article:

https://acrobatusers.com/tutorials/show_hide_fields

It has exactly what you need

TOPICS
Acrobat SDK and JavaScript, Windows

Views

979

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
Nov 16, 2017 0
Adobe Community Professional ,
Nov 16, 2017

Copy link to clipboard

Copied

Read this article:

https://acrobatusers.com/tutorials/show_hide_fields

It has exactly what you need

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
Reply
Loading...
Nov 16, 2017 0
New Here ,
Nov 17, 2017

Copy link to clipboard

Copied

Thanks for the link. A lot of reading, but was able to find the code needed for my issue.

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
Reply
Loading...
Nov 17, 2017 0
Adobe Community Professional ,
Nov 17, 2017

Copy link to clipboard

Copied

I knew you'd find it there! And now you know more about how Acrobat fields and scripts work. My work is done

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
Reply
Loading...
Nov 17, 2017 2
Contributor ,
Nov 17, 2017

Copy link to clipboard

Copied

Use the following script :

In "yes" :  

if (event.value == "Yes"){

this.getField("A_Comments").display=display.visible;}

else

{this.getField("A_Comments").display = display.hidden;}

In "No": 

if (event.value == "No"){

this.getField("A_Comments").display=display.hidden;}

else

{this.getField("A_Comments").display = display.visible;}

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
Reply
Loading...
Nov 17, 2017 0
New Here ,
Nov 17, 2017

Copy link to clipboard

Copied

Thanks, the behavior is not correct. Unchecking the "Yes" box did not hide the "A_Comments" field.

So, I used the following in the "YES" Box:

var nHide = event.target.isBoxChecked(0)?display.visible:display.hidden;

this.getField("A_Comments").display = nHide;

Clicking "yes" , on and off, would display and hide the "A_Comments" fields.

For "No", a plain checkbox works. As the above solved the display issue.

Thanks, rakeshk21205956

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
Reply
Loading...
Nov 17, 2017 0