We help IT Professionals succeed at work.

Adding Values from Specific Selected Radio buttons on Acro Form in Adobe PDF

shogun5
shogun5 asked
on
High Priority
72 Views
1 Endorsement
Last Modified: 2020-01-21
Hello Experts,

Need some help in calculating specific choices selected in radio button groups. I've search the net but not finding what I need. So have 18 radio button groups. One group for each 18 rows of questions and three choices (columns) in each row for Lower Risk, Moderate Risk and Higher risk. The naming convention looks like this:
Group 1: Risk1 Choices: LwrRsk1, ModRsk1, HighRsk1
Group 2, Risk2 Choices: LwrRsk2, ModRsk2, HighRsk2
Group 3: Risk3 Choices: LwrRsk3, ModRsk3, HighRsk3, etc.

I need a way to add up all the choices select for LwrRsk choices, all the values for the ModRsk choices and sum the values for all the HighRsk choices selected and display the value of the sums in respected text boxes called Lower Risk Total, Moderate Risk Total, High Risk Total.

Hoping someone can help me with this.

Attached is the form I am working with....

Thanks!
Suicidal_Risk_Screening_Tool-Fillabl.pdf
Comment
Watch Question

Scott FellDeveloper & EE Moderator
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2013

Commented:
Are you familiar with using JavaScript?

Example:
var total = radio1 + radio2 + radio3;

Author

Commented:
Yes.
How would I code this using Javascript?
Scott FellDeveloper & EE Moderator
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2013

Commented:
Let's start easy.

Here I have created 2 checkbox fields and one text field.

I changed the text field to a calculated field by editing (right click if you have to and select properties). Then go to the Calculate tab and I selected simplified field notation and then hit the edit button. I named field1 and field2 cb1 and cb2 respectively. My calculation is simply  cb1+cb2. After entering that, I clicked ok. Now you still have some tabs to check out. The main thing to to go to the format tab and under "Select Format Category" choose, "Number" from the drop down. I also set decimal places to 0. Hit close, then save.

See if this example gets you started.  Create a new pdf to play with just to recreate this simple example before moving on.

Now, in your own form, it is complex but take it in pieces and you can get it done. What I am confused on may be semantics. But you said in your question you are working with radio buttons but your form is a checkbox. The difference between a checkbox and a radio button is a checkbox is independent as in "check all that apply". With a radio button, only one of the group is selected as in, "Check one from the group that applies". Each radio button from the group will have different values but the one that will be calculated is the one that is checked.
formtest.pdf

Author

Commented:
Hello Scott,

I really appreciate you taking the time to write me back. But as you can see on the form I sent those are not checkboxes but rather radio buttons set up to look like check buttons. The purpose for this is to ensure that users cannot click on more than one "checkbox" per row. So here is the quandary. Using checkboxes  it makes sense using the export value to add but how would I do this using the specific radio button selected.

For example: Group 1: Risk1 Choices: LwrRsk1, ModRsk1, HighRsk1 How do I add 1 or get the export value of 1 when "ModRsk1" is selected in the Risk1 Group?

Thanks!
Scott FellDeveloper & EE Moderator
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2013

Commented:
I didn't catch that.

I did mention how to use radio groups though.  You will have multiple options with the same group name and different values.  I didn't check the values but lets assume low is 1, moderate is 2 and high risk is 3.

GROUP: Risk1
LwrRsk1 = 1
ModRsk1 = 2
HighRsk1  = 3

When ModRsk1  is selected then the Risk1  will have a value of 2

Author

Commented:
Thank you Scott.. How to I 'grab' the value of the LwrRsk1 choice in the Risk1 group. I don't see an export value like the checkbox example you provided. Wondering if you could provide an example again but this time using three radio buttons and one group this time.

Thanks!
no-export-value.png
Developer & EE Moderator
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2013
Commented:
I think some of the confusion may be from how you have this coded.  

I can see you have plans A.Details, B How prepared.... and so on. Then columns for Lower risk, Moderate  Risk and Higher Risk.  

Your radio button for A.Details has group Risk1 and values as LwRsk1, ModRisk1 and HighRsk1.  If you select Moderate Risk for A.Details, then the value for Risk1 will be ModRisk1.  

Instead, can you make the value of all Lower Risk =1, all Moderate Risk = 2 and Higher Risk = 3.  Then create a text field to calculate (risk1+risk2+risk3 ... risk16+risk17+risk18)/3.  That formula would go under the Options tab for the field and under Format tab set to a number without a decimal.  I think that should make the 2nd page of your form easier to use.

Author

Commented:
Hello Scott,

Thank you for your explanation. I'm so sorry that this is not 'clicking' with me.  I must be doing something wrong. Please see attached document. I set all Risk 1 values as "1", Risk 2 as "2" and Risk "3" as 3 and created a text field with calculated value as:  (risk1+risk2+risk3 ... risk16+risk17+risk18)/3. But the problem I am having is this. On page two I have a low Risk field, Mod Risk field and High Risk field. I need to add all the Risk 1 and place in Risk 1 field and all the Risk two and place in Mod Risk Field, etc. I have attached the pdf and believe I modified as you requested but it's not working or more acurately I am not modifying it properly. Can you check and let me know.?

Mike
Suicidal_Risk_Screening_Tool-Fillabl.pdf

Author

Commented:
Scott,
After looking over your comments and the form again I was able to figure out a way to make this work. Thank you so much for providing me the insights working with radio buttons and choices. Much appreciated!
Scott FellDeveloper & EE Moderator
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2013

Commented:
I am glad you figured it out. I have been busy today and couldn't follow up. How did you finally set up the form. I was going to say to change the bottom of the form to just write out the answer automatically instead of getting the user to do addition and figure it out on their own.

Author

Commented:
Well it may not be the prettiest solution but I just checked to see which value the group had, e.g., 1, 2 or 3 then I knew which column to write the value in. I just looped through each group and if the group had a value of 1 I just added to the 1 variable, the the group had a value of 2 I added to the 2 variable, etc. Then I wrote the final variable value in the appropriate column and was able to do the math from there. :-)