Highlighted

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

New Here ,
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! 

Adobe Community Professional
Correct answer by ls_rbls | Adobe Community Professional

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.

 

 

TOPICS
Acrobat SDK and JavaScript, How to

Views

81

Likes

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

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

New Here ,
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! 

Adobe Community Professional
Correct answer by ls_rbls | Adobe Community Professional

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.

 

 

TOPICS
Acrobat SDK and JavaScript, How to

Views

82

Likes

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
Aug 10, 2020 0
Adobe Community Professional ,
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

 

 

Likes

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
Reply
Loading...
Aug 10, 2020 0
Adobe Community Professional ,
Aug 10, 2020

Copy link to clipboard

Copied

Likes

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
Reply
Loading...
Aug 10, 2020 0
Adobe Community Professional ,
Aug 10, 2020

Copy link to clipboard

Copied

Likes

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
Reply
Loading...
Aug 10, 2020 0
New Here ,
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. 

Likes

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
Reply
Loading...
Aug 10, 2020 0
Adobe Community Professional ,
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.

 

 

Likes

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
Reply
Loading...
Aug 10, 2020 0
BarlaeDC LATEST
Adobe Community Professional ,
Aug 10, 2020

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Aug 10, 2020 1
New Here ,
Aug 10, 2020

Copy link to clipboard

Copied

That worked! Thank you so much for your help!

Likes

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
Reply
Loading...
Aug 10, 2020 0