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.
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;
Copy link to clipboard
Copied
What are the names of the radio-button groups, and are the export values the same in each group?
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?
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;
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.
Copy link to clipboard
Copied
Do you mean the highest value from all the totals?
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.
Copy link to clipboard
Copied
Do you have the definition text for each category in a text field?
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.
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.
Copy link to clipboard
Copied
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.
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.
Copy link to clipboard
Copied
You didn't apply the code I provided in the file you attached earlier. Did you do it now?
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.
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.
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. : )
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.
Copy link to clipboard
Copied
I have a question related to this thread.
I have a row with 3 radio buttons [checkY.group 1, checkN.group 1, checkZ.group 1] grouped to "Group 1"
and the same for 24 more rows. I cant group them in columns since only one radio button needs to be active.
Now I want to count all selected "checkY.group x" buttons, so my guess is there should be a way to just read all "checkY" buttons but it does not work like checkboxes. They can't be summarized for some reason. MAybe beacause they are inside a group?
Copy link to clipboard
Copied
ahh I got it solved with this tutorial blog
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.
has some possible coding to count the selected radio buttons selected in each column.