How do I Make Multiple Copies of a Radio Button AND keep the Java Script
Copy link to clipboard
Copied
I am trying to make multiple copies of a radio button group AND keep the Java Script that I have input. I have 1 group of 3 radio buttons that has a script, I seem to be unable to copy the radio button while still retaining the java script. It doesn't copy with the new buttons!
Copy link to clipboard
Copied
What mechanism are you using to copy the buttons?
When I copy a radio button using ctrl-C/ctrl-v, all properties are copied.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
If I use ctrl-C/ctrl-V-yes the properties are all copied but then when you select one of the buttons the other is selected as well. I would have to go back and rename them all.
Copy link to clipboard
Copied
Yes, when you copy fields you have to rename them. That's how it works. That's got nothing to do with the JavaScript.
An alternative to the copy/paste is to use the "Create Mulitple Copies" option on the Right Click pop up menu that appears when you have fields selected. I believe this option renames the fields.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
But as I said if I use the 'Create Multiple Copies' option, the java script does not copy. I am wondering how, or, if there is a way to create multiple copies of the radio button group and have the java script copy with it, without my having to go back and either rename every field (like with the ctrl-C/ctrl-V) or add the script (as with 'Create Multiple Copies') to every field separately. Maybe it cannot be done?
Copy link to clipboard
Copied
You need to be clear about what it is you want to do. The "Create Multiple Copies" feature gives each field a new name and copies the JavaScript. So you shouldn't be having a problem.
However, if it isn't working for you, there is a way through scripting to add scripts to a field. This would be relatively easy way to add scripts to the copied buttons.
What kind of script are you using? What does the script do?
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Maybe I am going about this wrong, here's my situation: When I select a group of 3 radio buttons and try to 'Create Multiple Copies' I get this message "Cannot create multiple copies of this selection. One or more fields in the selection have duplicates in this form."
I am unable to make multiple copies of the group of radio buttons. I can use 'Create Multiple Copies' and copy one button. What I would like to do is to copy the group of 3, 22 times (and keep the script). Here is the script I am using:
if(event.target.oldVal == event.target.value)event.target.value = "Off";
it allows the user to uncheck the radio button, otherwise I found that one button out of the group would always have to be selected once the user selects one in the group (ie: they can't uncheck a button and leave the group blank) and I don't want that.
Copy link to clipboard
Copied
So you have a couple of issues.
First, as the message states, there is a duplicate of the fields you are trying to copy. Get rid of it and "Create Multiple Copies" will work. You can just rename the duplicate to something else.
Next, you don't need the script for turning the radiobutton off. Just use CheckBoxes instead of radio buttons.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Check boxes are not an option for this project, it has to be radio buttons. And I don't want the user to be able to select more than 1 in every group of 3.
Copy link to clipboard
Copied
In a PDF, Checkboxes and Radio buttons are almost the same thing. Give two check boxes the same name and different export values and they act just like two radio buttons, except you can click them off.
Use the Acrobat JavaScript Reference early and often

