calculating radio buttons

New Here ,
Apr 07, 2018 Apr 07, 2018

Copy link to clipboard

Copied

Help with radio buttons. I need to calculate a specific button in a given group/row.

I have a form with radio buttons. I've roughly set the radio buttons in for now. I need to have each column total Random, Informal, Formal and Dynamic. So only one radio button selected from each horizontal row 1, 2a, 2b etc.

I'm guessing it has something to do with scripting which I'm not very familiar with.

Form-Example.png

TOPICS
Acrobat SDK and JavaScript

Views

1.1K

Likes

translate

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
community guidelines

correct answers 1 Correct Answer

Most Valuable Participant , Apr 08, 2018 Apr 08, 2018
Let's say there are five groups and you want to count in how many of them the value "1" is selected.Use this code as the custom calculation script of the total field:var total = 0;for (var i=1; i<=5; i++) {    var f = this.getField("Group "+i);    if (f.valueAsString=="1") total++;}event.value = total;

Likes

translate

Translate

Translate
Most Valuable Participant ,
Apr 07, 2018 Apr 07, 2018

Copy link to clipboard

Copied

What are the names of the radio-button groups, and are the export values the same in each group?

Likes

translate

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
community guidelines
New Here ,
Apr 08, 2018 Apr 08, 2018

Copy link to clipboard

Copied

The radio button  are Group 1 2, 3 etc. and value of just 1 per checkbox or radio button selection. Plus Choice 1, 2, 3, 4. I'm very new to scripting so is it possible to write one out and I can apply one to my document?

Likes

translate

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
community guidelines
Most Valuable Participant ,
Apr 08, 2018 Apr 08, 2018

Copy link to clipboard

Copied

Let's say there are five groups and you want to count in how many of them the value "1" is selected.

Use this code as the custom calculation script of the total field:

var total = 0;

for (var i=1; i<=5; i++) {

    var f = this.getField("Group "+i);

    if (f.valueAsString=="1") total++;

}

event.value = total;

Likes

translate

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
community guidelines
New Here ,
Apr 08, 2018 Apr 08, 2018

Copy link to clipboard

Copied

Thank you so much!!!!

I have it working now...I will refine the entire document and will be back with a few additional questions. Example once the participant completes the survey we want to total the score which I can now do. Plus with the highest total we want a  definition to reveal and explain why and what they are the strongest in the area the totaled the highest in.

Likes

translate

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
community guidelines
Most Valuable Participant ,
Apr 08, 2018 Apr 08, 2018

Copy link to clipboard

Copied

Do you mean the highest value from all the totals?

Likes

translate

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
community guidelines
New Here ,
Apr 08, 2018 Apr 08, 2018

Copy link to clipboard

Copied

So from the four categories Random, Informal, Formal and Dynamic they will be the highest in one of these once complete. From that we have a definition for each category we will reveal. We would prefer to not show all 4 definition just they 1 they scored the highest in.

Currently the form has 13 questions, for the help post I used just 5. I'm hoping the have on a separate page the total score and reveal the definition of the 1 category they scored the highest in.

Likes

translate

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
community guidelines
Most Valuable Participant ,
Apr 08, 2018 Apr 08, 2018

Copy link to clipboard

Copied

Do you have the definition text for each category in a text field?

Likes

translate

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
community guidelines
New Here ,
Apr 08, 2018 Apr 08, 2018

Copy link to clipboard

Copied

So its not working completely as I need it. Random, Informal, Formal and Dynamic each column need its one total calculated from the 13 questions. As you see below the 4 columns/categories total the same amount, I'm guessing somewhere I need to target/callout the total box.

Form-Example2.png

Likes

translate

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
community guidelines
Most Valuable Participant ,
Apr 08, 2018 Apr 08, 2018

Copy link to clipboard

Copied

I'll need to see the actual file to be able to help you further.

You can share it via Dropbox, Google Drive, Adobe Cloud, etc.

Likes

translate

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
community guidelines
New Here ,
Apr 08, 2018 Apr 08, 2018

Copy link to clipboard

Copied

Likes

translate

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
community guidelines
Most Valuable Participant ,
Apr 08, 2018 Apr 08, 2018

Copy link to clipboard

Copied

All of your radio-buttons have the same export value ("Radio button choice"). You need to give each one in the group a unique value for it to work.

Likes

translate

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
community guidelines
New Here ,
Apr 08, 2018 Apr 08, 2018

Copy link to clipboard

Copied

OK so I've adjusted that but they all track the same value in each total box at the bottom. I need the total box depending on which single choice is selected in each column to track differently. Ultimately when finished only one Colum will have a larger total score.

Do I need to have some type of coding in each total text field? Right now I just have each Group of radio buttons targeted.

Likes

translate

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
community guidelines
Most Valuable Participant ,
Apr 08, 2018 Apr 08, 2018

Copy link to clipboard

Copied

You didn't apply the code I provided in the file you attached earlier. Did you do it now?

Likes

translate

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
community guidelines
New Here ,
Apr 08, 2018 Apr 08, 2018

Copy link to clipboard

Copied

I placed that code in the Radio Buttons and it worked for just the one total score text box. Should of I placed that code just in the Bottom text box for the score? Currently I have it in both the Radio buttons and in the total text box at the bottom.

Likes

translate

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
community guidelines
Most Valuable Participant ,
Apr 08, 2018 Apr 08, 2018

Copy link to clipboard

Copied

As I wrote, it should be used as the custom calculation script of the text field where you want the result to appear.

Likes

translate

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
community guidelines
New Here ,
Apr 08, 2018 Apr 08, 2018

Copy link to clipboard

Copied

http://https://pcdhc.box.com/s/v2a1ev1hfwhgntauiq5wzzrxznfsm529

I've uploaded a new file and its working but still just seems to track to all results to the same total. I need each column to track the one radio button choice per question.

I truly apologize and thank you for you time. I'm very new to scripting and my need to review more help me documents. I'm sure this is all user error.  :  )

Likes

translate

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
community guidelines
Most Valuable Participant ,
Apr 08, 2018 Apr 08, 2018

Copy link to clipboard

Copied

It doesn't seem you applied any of the changes I described. I can't help you further, unless you want me to do it for you, for a fee.

Likes

translate

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
community guidelines
LEGEND ,
Apr 07, 2018 Apr 07, 2018

Copy link to clipboard

Copied

You should have the radio button in each row in the same exclusionary group and each button has a unique export value. This will result in at most only one item selected in a row. Note you will not be able to unselect a button in a row by clicking on it, you will need a some additional scripting to do that.

Acrobat PDF count dropdown choices

has some possible coding to count the selected radio buttons selected in each column.

Likes

translate

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
community guidelines