Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Hide text field on radio button for JSNewbie

New Here ,
Jun 06, 2018 Jun 06, 2018

Hello,

I have read several similar posts on various ways to do this, but I am still stuck. I am completely NEW to javascript. This is my first attempt!

I've tried to copy similar JS examples, but replace with my labels, but i must be doing it wrong somewhere.

I need to hide a text box based on a radio selection in two instances.

I am running Adobe DC Pro.

I have 2 radio buttons in a group with a text field box for each choice.

Radio buttons are named "Group3" with unique names "Choice1" & "Choice2".

Text field boxes are named "G3C1" and "G3C2"

Goal: If Choice1 is selected, then text box G3C2 becomes hidden. Or if choice 2 is selected, then G3C1 becomes hidden.

Can someone provide me with the exact JS for this?

Radio button Hide Function.JPG

Appreciate any help - Thank you

TOPICS
Acrobat SDK and JavaScript , Windows
825
Translate
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

Community Expert , Jun 06, 2018 Jun 06, 2018

Create a hidden text field and set this code as its custom calculation script:

var v = this.getField("Group3").valueAsString;

this.getField("G3C1").display = (v=="Choice1") ? display.visible : display.hidden;

this.getField("G3C2").display = (v=="Choice2") ? display.visible : display.hidden;

Translate
Community Expert ,
Jun 06, 2018 Jun 06, 2018

Create a hidden text field and set this code as its custom calculation script:

var v = this.getField("Group3").valueAsString;

this.getField("G3C1").display = (v=="Choice1") ? display.visible : display.hidden;

this.getField("G3C2").display = (v=="Choice2") ? display.visible : display.hidden;

Translate
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
New Here ,
Jun 06, 2018 Jun 06, 2018
LATEST

Awesome! That works!

Thank you

Translate
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