Skip to main content
Participant
February 25, 2025
Question

text field triggered by radio buttion

  • February 25, 2025
  • 3 replies
  • 172 views

Is it possible to have a text field show and can be editable when a specific radio button is selected? I have a text field (text 1) that i want to show when radio button (other) from (group1) is selected and is able to be typed into. i would like this to remain hidden when the other radio buttons are selected. 

3 replies

try67
Community Expert
Community Expert
February 25, 2025

Be aware that just hiding the field does not clear its value, so if you plan on exporting the form data to another format (and even if you're not, it's just good practice) it's recommended to not just hide the field, but actually clear it.

To do so you can use this code as its custom calculation script:

 

if (this.getField("group1").valueAsString=="other") {
	event.value = "";
	event.target.display = display.hidden;
} else event.target.display = display.visible;
Thom Parker
Community Expert
Community Expert
February 25, 2025

You will find the answer here:

https://www.pdfscripting.com/public/Hiding-and-Showing-Form-Fields.cfm?sd=40

 

The simple way to do this is to use the MouseUp event on a radio button. You'll need to put code on every radio button that affects the visibility of the field. 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
PDF Automation Station
Community Expert
Community Expert
February 25, 2025

Enter the following custom calculation script in the text field:

this.getField("group1").value=="other"?event.target.display=display.visible:event.target.display=display.hidden;