text field triggered by radio buttion
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
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.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
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;

