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

Changing radio button option based on another

Participant ,
Jun 17, 2024 Jun 17, 2024

Copy link to clipboard

Copied

I have a form that has 2 sets of radio buttons (on and offs).

 

I have been given a constraint that both EZ-Start and Auto-Trial both cannot be set to On at the same time. It has to be one of the other.

 

Is there a way that if EZ-Start is set to On, then it automatically sets Auto-Trial to "Off" and vice versa? I assume this would have to be done with Javascript somehow?

 

Screenshot 2024-06-18 at 9.47.29 AM.png

TOPICS
How to , JavaScript , PDF forms

Views

95

Translate

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 ,
Jun 17, 2024 Jun 17, 2024

Copy link to clipboard

Copied

Yes, Use a Mouse Up script on both of the "On" radio buttons, to force the other radio button group to Off. 

for example, here's the script for the EZ-Start On button. Note that I'm guessing the field name. You'll need to replace the name in my script with the exact name that is used on your form. 

 

this.getField("Auto-Trial").value = "Off";

 

 

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

Votes

Translate

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
Enthusiast ,
Jun 17, 2024 Jun 17, 2024

Copy link to clipboard

Copied

LATEST

This will work if you want the user to clear the other group when you turn the group on, instead of togging it to off.

Votes

Translate

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
Enthusiast ,
Jun 17, 2024 Jun 17, 2024

Copy link to clipboard

Copied

In a Mouse Up action of each button, set the value of the other group to the export value of the button in that group that corresponds with the Off or On lable.  Assuming the field group names are EZ-Start and Auto-Trial, and the export values are Choice1 and Choice2, enter the following script in both EZ-start buttons:

 

if(event.target.value=="Choice1")

{this.getField("Auto-Trial").value="Choice2"}

else

{this.getField("Auto-Trial").value="Choice1"}

 

Enter the following script as a Mouse Up action in both Auto-Trial buttons:

 

if(event.target.value=="Choice1")

{this.getField("EZ-Start").value="Choice2"}

else

{this.getField("EZ-Start").value="Choice1"}

Votes

Translate

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