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

Set unchecked radio buttons to zero.

JoeB_NewYork
Registered: Dec 6 2007
Posts: 7
Answered

I have a 10 items survey.
Each item has 4 radio buttons (scored 0 to 3).
I want to display total score in a calculated field.
If all radio buttons for an item are unchecked, I want to count it as zero.
Otherwise, any unchecked item causes a "NaN" in the total field.

(I do not want the radio button for "zero" to be visibly filled in by default.)

Any suggestions???

Thanks!

My Product Information:
Acrobat Pro 8.1.3, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Your calculated field will have to use a custom calculation script. If you've created your fields in Acrobat (as opposed to LiveCycle Designer), a radio button group will have a value of "Off" when none in the group is selected, which is why you're getting "NaN". The script will have to ignore any "Off" values. For example, assuming ten groups named (rb1 - rb10):

(function () {// Custom calculation script for a text field // Initializevar sum = 0;var i, val // Loop through the ten radio button groups...for (i = 1; i < 11; i += 1) { // Get current radio button valueval = getField("rb" + i).value; // Add the value if it's not "Off"if (val !== "Off") {sum += val;}} if (sum > 0) {// Set this field's value to the sumevent.value = sum;} else {// Blank this fieldevent.value = "";}})();

George
JoeB_NewYork
Registered: Dec 6 2007
Posts: 7
Terrific!
Many thanks...
Joe