Skip to main content
andreah75641828
Known Participant
November 7, 2018
Answered

Assign numerical values to radio dials

  • November 7, 2018
  • 1 reply
  • 2882 views

I have a section of Yes/No radio dials. Each of these dials needs to equal a numerical value for calculating a score for example:

Do you like the color red?

-Yes (3 points)

-No (3 points)

Do you like ice cream?

-Yes (1 point)

-No (1 point)

(Each question holds a different numerical value for calculating a score)

The Yes and No radio dials equal the same number for each individual question; however, each question has its own value. I need to assign values to the Yes and No radio dials so that I can total them by their answers of Yes or No based on their assigned values.

Is there any script to do this or is there a simple setting I'm missing to accomplish this? Thanks!

This topic has been closed for replies.
Correct answer try67

And the code still doesn't work for me. Now it's not calculating anything for me. What's the exact code you used that worked so I can make sure I didn't enter something wrong?


The problem is with the script for TOTAL_RISK_SCORE. Namely, you forgot to put quotes around the field names...

The code I used was:

var total = 0;

if (this.getField("Group1").valueAsString!="Off") total+=3;

if (this.getField("Group2").valueAsString!="Off") total+=2;

if (this.getField("Group3").valueAsString!="Off") total+=3;

// etc.

event.value = total;

I placed it as the custom calculation script of "PMTotal", just to test it out.

1 reply

try67
Community Expert
Community Expert
November 7, 2018

You can apply the value as the export value of both fields, but that's not good practice.

Instead, you can do something a bit more complicated, like setting the export values to "Yes|3" and "No|3" and then parse the value of the field to get the number of points for it. Alternatively, you can hard-code the number of points per field in your code.

andreah75641828
Known Participant
November 8, 2018

Unfortunately, I have no idea how to do that haha

try67
Community Expert
Community Expert
November 20, 2018

Are you saying to change the "Choice1" and "Choice2" under each group to "Yes" and "No"? Sorry I don't understand what you mean by the export value.


Yes, that's what I mean.