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!
2 Correct answers
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
...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
...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
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Here's a better example: https://community.adobe.com/t5/acrobat/java-script-for-radio-button-values/td-p/9268021?page=1
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.
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.
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
Copy link to clipboard
Copied
That worked! Thank you so much for your help!

