Skip to main content
Known Participant
Jun 14, 2025 7:19 PM UTC
Answered

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

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

JR Boulay
JR BoulayCorrect answer
Community Expert
Jun 18, 2025 10:25 AM UTC

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

10 replies

JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
Jun 18, 2025 10:25 AM UTC

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;}
Translate
Acrobate du PDF, InDesigner et Photoshopographe
Known Participant
Jun 18, 2025 12:50 PM UTC

That worked.  Thank you!

Translate
JR Boulay
Community Expert
Community Expert
Jun 15, 2025 10:12 PM UTC

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;}
Translate
Acrobate du PDF, InDesigner et Photoshopographe
Known Participant
Jun 16, 2025 12:55 PM UTC

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

Translate
Known Participant
Jun 14, 2025 7:33 PM UTC

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

Translate
Known Participant
Jun 15, 2025 9:30 PM UTC

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