Skip to main content
Participant
May 20, 2025
Answered

2 Radio button groups to hide multiple text field on No

  • May 20, 2025
  • 2 replies
  • 411 views

Im creating a form with two radio buttons: CRadio and FRadio both with yes or no option and five text fields: TF1, TF2, TF3, TF4, TF5 to be visible unless both CRadio and FRadio are "No". Ive tried to add an action on Mouse Up in CRadio and FRadio but it if you select Yes on either group it wont display the text fields again

this.getField("TF1").display = display.hidden;
this.getField("TF2").display = display.hidden;
this.getField("TF3").display = display.hidden;
this.getField("TF4").display = display.hidden;
this.getField("TF5").display = display.hidden;

Correct answer heather_4360

This was what I needed! Thank you for yor help Thom!

2 replies

JR Boulay
Community Expert
Community Expert
May 24, 2025

[MOVED TO THE ACROBAT DISCUSSIONS]

Acrobate du PDF, InDesigner et Photoshopographe
Thom Parker
Community Expert
Community Expert
May 21, 2025

So that script just hides all the fields.

Since the required behavior comes from two sources, the "CRadio" and "FRadio", the best solution is to use a calculation script. This script can be placed in the Custom Calculation for any of the TF fields. But it can only be in one. 

The key to the script is that "No" radio button has an export value of "No". If this is not true then the script will need to be changed to match the export value of the "No" radio button. 

You can read all about scripts for showing and hiding fields here:https://www.pdfscripting.com/public/Hiding-and-Showing-Form-Fields.cfm

 

Here's the script. 

 

// Assuming that the export value for the "No" radio button is "No"
var bHide = (this.getField("CRadio").value == "No") && (this.getField("FRadio").value == "No");
this.getField("TF1").display = bHide?display.hidden:display.visible;
this.getField("TF2").display = bHide?display.hidden:display.visible;
this.getField("TF3").display = bHide?display.hidden:display.visible;
this.getField("TF4").display = bHide?display.hidden:display.visible;
this.getField("TF5").display = bHide?display.hidden:display.visible;

  

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
heather_4360AuthorCorrect answer
Participant
May 29, 2025

This was what I needed! Thank you for yor help Thom!