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

How to make a radio button in one group, select a radio button in a different group

Community Beginner ,
Aug 10, 2020 Aug 10, 2020

Copy link to clipboard

Copied

Hello,

 

I'm looking for the Javascript to copy and paste in an Adobe PDF fillable form. 

 

I have two groups, Group1 with options A and B, and Group2 with Options C and D. I want to make it so when someone clicks Option B in Group1, then Option C in Group2 is automatically selected. I've done this before with checkboxes, but I can't seem to get it to work with radio buttons. 

 

Thank you for your help! 

TOPICS
Acrobat SDK and JavaScript

Views

1.6K

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

correct answers 2 Correct answers

Community Expert , Aug 10, 2020 Aug 10, 2020

Just make sure that  when you create the two radio button for Group1 that the radio buttons in one group have the same FieldName but different export values.

 

By default, when you right-click on the radio button field  and select "Create Multiple Copies", you'll notice that the export values will be assigned automatically as Choice1, Choice2, etc. (but you can change them to whatever you need them to be)

 

Do the same for Group2 radio buttons.

 

Then in Group 1,  add a  mouse-up action on the option

...

Votes

Translate

Translate
Community Expert , Aug 10, 2020 Aug 10, 2020

Hi,

 

Using this with Radio Buttons ( that are in different groups the code for this is fairly straight forward.

 

If you add this code to Group 1 box A :

this.getField("Group2").checkThisBox(0, true);

And in Group 1 box B :

this.getField("Group2").checkThisBox(1, true);

 

Because of the way radio buttons work, this also auto unchecks the other one.

 

Gotcha : The radio buttons as added in to the group in the order that you create them in that group, not the order they are on the page.

 

Hope th

...

Votes

Translate

Translate
Community Expert ,
Aug 10, 2020 Aug 10, 2020

Copy link to clipboard

Copied

That is achieved by  getting the index of the checked radio button (zero-based index method)

 

I just posted a question having a similar issue but I think I found the answer.

 

Look in the Adobe Acrobat SDK, Developing Acrobat Applications Using JavaScript, Page 81  "Setting Acrobat form field properties"   specifically in the "Radio button fields" section Example 6.3Accessing individual radio button widgets

 

 

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
Community Expert ,
Aug 10, 2020 Aug 10, 2020

Copy link to clipboard

Copied

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
Community Expert ,
Aug 10, 2020 Aug 10, 2020

Copy link to clipboard

Copied

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
Community Beginner ,
Aug 10, 2020 Aug 10, 2020

Copy link to clipboard

Copied

Thank you for your responses! Unfortunately, I'm still unable to figure it out. 
 In another pdf form, I used the following so when checkbox "A" was clicked, 2 other checkboxes were automatically clicked. 

this.getField("checkbox8").value = event.target.value;

this.getField("checkbox8").readonly = (event.target.value == "Yes")

this.getField("checkbox4").value = event.target.value;

this.getField("checkbox4").readonly = (event.target.value == "Yes")

So I was just trying to figure out how to make it radio buttons instead of checkboxes, and 1 option is automatically clicked instead of 2. The script above I copied directly from another forum and just changed my checkbox number. 

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
Community Expert ,
Aug 10, 2020 Aug 10, 2020

Copy link to clipboard

Copied

Just make sure that  when you create the two radio button for Group1 that the radio buttons in one group have the same FieldName but different export values.

 

By default, when you right-click on the radio button field  and select "Create Multiple Copies", you'll notice that the export values will be assigned automatically as Choice1, Choice2, etc. (but you can change them to whatever you need them to be)

 

Do the same for Group2 radio buttons.

 

Then in Group 1,  add a  mouse-up action on the option B radio button:

 

 

if (event.target.value !="Off") {this.getField("Group2").checkThisBox(0, true)}

 

  

That's pretty much it.

 

 

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
Community Expert ,
Aug 10, 2020 Aug 10, 2020

Copy link to clipboard

Copied

LATEST

Hi,

 

Using this with Radio Buttons ( that are in different groups the code for this is fairly straight forward.

 

If you add this code to Group 1 box A :

this.getField("Group2").checkThisBox(0, true);

And in Group 1 box B :

this.getField("Group2").checkThisBox(1, true);

 

Because of the way radio buttons work, this also auto unchecks the other one.

 

Gotcha : The radio buttons as added in to the group in the order that you create them in that group, not the order they are on the page.

 

Hope this helps.

 

Malcolm

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
Community Beginner ,
Aug 10, 2020 Aug 10, 2020

Copy link to clipboard

Copied

That worked! Thank you so much for your help!

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