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

Show Text Field if Checkbox checked and another Text Field contains text

Community Beginner ,
Jun 14, 2025 Jun 14, 2025

If have Checkbox1, Text Field1, Text Field2, Text Field3, Text Field4 and Text Field5.  I would like to show and hide as follows:

 

CB1 not checked and TF1 contains no text = show TF2, hide TF3, TF4 and TF5

CB1 not checked and TF1 contains text = show TF3, hide TF2, TF4 and TF5

CB1 checked and TF1 contains text = show TF4, hide TF2, TF3 and TF5

CB1 checked and TF1 contains no text = show TF5, hide TF2, TF3 and TF4

TOPICS
JavaScript , PDF , PDF forms
465
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
1 ACCEPTED SOLUTION
Community Expert ,
Jun 18, 2025 Jun 18, 2025

In the script provided by JR Boulay it's missing 'C' in each condition

Oops!

It's always better with a test file.

Attached.

 

var CB1 = this.getField("Checkbox1");
var Tx1 = this.getField("Text Field1");
var B1 = this.getField("Button1");
var B2 = this.getField("Button2");
var B3 = this.getField("Button3");
var B4 = this.getField("Button4");

B1.display = display.hidden;
B2.display = display.hidden;
B3.display = display.hidden;
B4.display = display.hidden;

if (CB1.value === "Off" && Tx1.value === Tx1.defaultValue) {B1.display = display.noPrint;}
else if (CB1.value === "Off" && Tx1.value != Tx1.defaultValue) {B2.display = display.noPrint;}
else if (CB1.value != "Off" && Tx1.value != Tx1.defaultValue) {	B3.display = display.noPrint;}
else if (CB1.value != "Off" && Tx1.value === Tx1.defaultValue) {B4.display = display.noPrint;}

Acrobate du PDF, InDesigner et Photoshopographe

View solution in original post

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
Community Beginner ,
Jun 14, 2025 Jun 14, 2025

When I said show, what I meant to say was visible but doesn't print.

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
Community Beginner ,
Jun 15, 2025 Jun 15, 2025

One more update.  I have buttons, not text fields.  The correct question is:

 

If have Checkbox1, Text Field1, Button1, Button2, Button3 and Button4.  I would like to noPrint and hide as follows:

 

CB1 not checked and TF1 contains no text = noPrint B1, hide B2, B3 and B4

CB1 not checked and TF1 contains text = noPrint B2, hide B1, B3 and B4

CB1 checked and TF1 contains text = noPrint B3, hide B1, B2 and B4

CB1 checked and TF1 contains no text = noPrint B4, hide B1, B2 and B3

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
Community Expert ,
Jun 15, 2025 Jun 15, 2025

Add an invisible text field and place this script as calculation script:

 

var CB1 = this.getField("Checkbox1");
var Tx1 = this.getField("TextField1");
var B1 = this.getField("Button1");
var B2 = this.getField("Button2");
var B3 = this.getField("Button3");
var B4 = this.getField("Button4");

B1.display = display.hidden;
B2.display = display.hidden;
B3.display = display.hidden;
B4.display = display.hidden;

if (B1.value === "Off" && Tx1.value === Tx1.defaultValue) {B1.display = display.noPrint;}
else if (B1.value === "Off" && Tx1.value != Tx1.defaultValue) {B2.display = display.noPrint;}
else if (B1.value != "Off" && Tx1.value != Tx1.defaultValue) {	B3.display = display.noPrint;}
else if (B1.value != "Off" && Tx1.value === Tx1.defaultValue) {B4.display = display.noPrint;}

Acrobate du PDF, InDesigner et Photoshopographe
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
Community Beginner ,
Jun 16, 2025 Jun 16, 2025

Can't seem to get it to work.  I have attached the file.

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
Community Beginner ,
Jun 17, 2025 Jun 17, 2025

Entering text in Text Field1 makes Button3 visible, removing text makes Button4 visible.  Checking Checkbox1 has no effect.

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
Community Expert ,
Jun 17, 2025 Jun 17, 2025

In the script provided by JR Boulay it's missing 'C' in each condition, it should look like this if(CB1.value

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
Community Beginner ,
Jun 17, 2025 Jun 17, 2025

I used this now but nothing becomes visible:

 

var CB1 = this.getField("Checkbox1");
var Tx1 = this.getField("TextField1");
var B1 = this.getField("Button1");
var B2 = this.getField("Button2");
var B3 = this.getField("Button3");
var B4 = this.getField("Button4");

B1.display = display.hidden;
B2.display = display.hidden;
B3.display = display.hidden;
B4.display = display.hidden;

if (CB1.value === "Off" && Tx1.value === Tx1.defaultValue) {B1.display = display.noPrint;}
else if (CB1.value === "Off" && Tx1.value != Tx1.defaultValue) {B2.display = display.noPrint;}
else if (CB1.value != "Off" && Tx1.value != Tx1.defaultValue) { B3.display = display.noPrint;}
else if (CB1.value != "Off" && Tx1.value === Tx1.defaultValue) {B4.display = display.noPrint;}

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
Community Expert ,
Jun 17, 2025 Jun 17, 2025

Your field name is "Text Field1" not "TextField1".

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
Community Expert ,
Jun 18, 2025 Jun 18, 2025

In the script provided by JR Boulay it's missing 'C' in each condition

Oops!

It's always better with a test file.

Attached.

 

var CB1 = this.getField("Checkbox1");
var Tx1 = this.getField("Text Field1");
var B1 = this.getField("Button1");
var B2 = this.getField("Button2");
var B3 = this.getField("Button3");
var B4 = this.getField("Button4");

B1.display = display.hidden;
B2.display = display.hidden;
B3.display = display.hidden;
B4.display = display.hidden;

if (CB1.value === "Off" && Tx1.value === Tx1.defaultValue) {B1.display = display.noPrint;}
else if (CB1.value === "Off" && Tx1.value != Tx1.defaultValue) {B2.display = display.noPrint;}
else if (CB1.value != "Off" && Tx1.value != Tx1.defaultValue) {	B3.display = display.noPrint;}
else if (CB1.value != "Off" && Tx1.value === Tx1.defaultValue) {B4.display = display.noPrint;}

Acrobate du PDF, InDesigner et Photoshopographe
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
Community Beginner ,
Jun 18, 2025 Jun 18, 2025
LATEST

That worked.  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