Skip to main content
matth92962896
Participant
June 6, 2018
Answered

Hide text field on radio button for JSNewbie

  • June 6, 2018
  • 1 reply
  • 909 views

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?

Appreciate any help - Thank you

This topic has been closed for replies.
Correct answer try67

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;

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 6, 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;

matth92962896
Participant
June 6, 2018

Awesome! That works!

Thank you