These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Yes/ No Question Selects All But Answers Can Be Changed

kerib81
Registered: Nov 15 2011
Posts: 3

I am creating a fillable pdf in Acrobat Standard. I have a section of the form that has many yes or no questions. It is likely if the user answers yes to one, they are all yes and the same with no. However, there may be a rare instance that is not the case. So, I would like the user to be able to select yes for all of the checkmarks for yes to be checked, but for the to be able to go and change the couple of answers that might not be that way. I want to do this so they don't have to check 40 yes and no boxes and to save them some time. I'm thinking I could run a javascript action to do this, but I have no idea how to write the code. Does anyone know how to do what I am asking?
 
Thank you!

try67
Expert
Registered: Oct 30 2008
Posts: 2398
What are the names of your fields?

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

kerib81
Registered: Nov 15 2011
Posts: 3
Right now, I have them all name differently according to the question, but I can change it if needed. What I am creating is a design request form for event invitations that often have the same information. Sometimes it changes though. An example of a portion of the section is below. If the number of shooters remains 10 on the invite, then they choose yes. If not no, and then they write the number in a space. Each sponsor level has a different name, so that's the way I named the fields. For example Host Sponsor is named Host Shooters with Yes (or No) as the export value. There is also a column for price, hence using Shooters in the name.

Host Sponsor:
10 Shooters Yes No __________

Transportation Sponsor:
10 Shooters Yes No __________

There are about 25 questions, and I just want them to be able to select yes or no for all and then change the few that they might need. Make sense?
try67
Expert
Registered: Oct 30 2008
Posts: 2398
I understood what you wanted to do. The reason I asked is because if the fields were named "Question1", "Question2", etc., it would be much easier. But let's say each fields is named differently.
What you can do is the following:
- You define an array of all the fields' names and then create a method to set all of their values.
- You create buttons in your form and call this method from the MouseUp action.

The method would look something like this:
  1. function setAllFieldsValue(v) {
  2. var fieldsNames = ["Host Sponsor", "Transportation Sponsor"]; // add more items as required
  3. for (var i in fieldsNames) {
  4. this.getField(fieldsNames[i]).value = v;
  5. }
  6. }
And so, for the button that supposes to set the radio buttons to "Yes", use this:
setAllFieldsValue("Yes");

And the same for the button that sets them all to "No":
setAllFieldsValue("No");

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

kerib81
Registered: Nov 15 2011
Posts: 3
I'm sorry... coding and understanding this is still really new to me. To understand, I need it broken out a little more. So, let's just say "Host Sponsor" and "Transportation Sponsor" are the only two questions. For the question that sets them all to yes, how many javascript actions should there be for the question asking yes? And what would each javascript button say?

Then, for the Host Sponsor button and the Transportation Sponsor button, how many javascript actions would there be and what would they say?

Thanks for your help.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
The radio buttons themselves should not change. I'm suggesting to create separate buttons and label them "Set all to Yes" and "Set all to No", or something like that. The buttons' MouseUp action would be the last two bits of code. The main function should be embedded as a doc-level script (how you do that depends on your version of Acrobat, which you didn't mention).
That way you can easily set all of the radio buttons to the same value, but could still edit each of them independently.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com