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

text field triggered by radio buttion

New Here ,
Feb 25, 2025 Feb 25, 2025

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. 

TOPICS
How to , JavaScript , PDF forms

Views

53
Translate

Report

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 ,
Feb 25, 2025 Feb 25, 2025

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;

 

Votes

Translate

Report

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 ,
Feb 25, 2025 Feb 25, 2025

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. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Report

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 ,
Feb 25, 2025 Feb 25, 2025

Copy link to clipboard

Copied

LATEST

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;

Votes

Translate

Report

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