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

Conditional formatting for radio buttons and text fields.

New Here ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

I'm using Adobe Acrobat Pro DC and creating a form. I have a set of 2 radio buttons with a group name of "FMLA Choice". The radio button choices are Yes and No. If the user selects Yes, I want a text box called "Field1" to appear. If the user selects No, I want a text box called "Field2" to appear. If the user does not select either radio button, I want neither of the text boxes to show.

 

Using the code below, I can get the text boxes to appear if the user selects Yes or No, but I can't get the text fields to stay hidden if neither choice is selected. I have the code as an Action on Mouse Up - Run a JavaScript - on both radio buttons. I think I'm missing something obvious.

 

var Q = this.getField("FMLA Choice");

var A = this.getField("Field1");

var B = this.getField("Field2");

if (Q.value === "") {

A.hidden = true;

B.hidden = true;

}if (Q.value === "Yes") {

A.hidden = false;

B.hidden = true;

}

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

A.hidden = true;

B.hidden = false;

}

TOPICS
PDF forms

Views

2.3K

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

Community Expert , Sep 11, 2020 Sep 11, 2020

You can use this code as Custom Calculation Script of both fields:

var Q = this.getField("FMLA Choice");
if(Q != "Yes" && Q != "No"){
event.target.display = display.hidden;}

Votes

Translate

Translate
Community Expert ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

LATEST

You can use this code as Custom Calculation Script of both fields:

var Q = this.getField("FMLA Choice");
if(Q != "Yes" && Q != "No"){
event.target.display = display.hidden;}

Votes

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