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

Radio Button Calculations...I need YOUR help!

RussellsRules
Registered: Dec 10 2007
Posts: 10

I am creating a scoresheet for monitoring customer service representatives in a call center. My score sheet has several different categories and each category is weighted accordingly.

Question 1 -
How do I create general calculations for radio buttons? Each rep is scored on a based on the following: Exceeds Expecatations, Very Good, Average, Below Average, Failing and N/A. Each one has an export value (1-5). However, if N/A is selected, the value becomes 0 instead of N/A. Any suggestions on that? I have used the following Script thus far which places the value from the radio button in the text box. I'm thinking I need a lot more than this though.

event.value = this.getField("MyRadioButtons").value;

Questions 2 -
Is there a way to weight each category accordingly? For example, if I want the rep's greeting to be 10% of the overall score and their closing to be 50% and the friendliness to be 40% over the overall score, am I able to do that?

I apologize for my lack of knowledge with this. I'm great at creating the form, but the calcs/Java have meen making me crazy!

Any help would be great. Thanks.

Thank you,

Russell

My Product Information:
Acrobat Pro 8.1.2, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
caliboyoc wrote:
Question 1 -
How do I create general calculations for radio buttons? Each rep is scored on a based on the following: Exceeds Expectations, Very Good, Average, Below Average, Failing and N/A. Each one has an export value (1-5). However, if N/A is selected, the value becomes 0 instead of N/A. Any suggestions on that? I have used the following Script thus far which places the value from the radio button in the text box. I'm thinking I need a lot more than this though.

event.value = this.getField("MyRadioButtons").value;
You do not need a text box for the score of each row of radio button but you probably want a text box to accumulate each category set of radio buttons. You can either write a complex script for each category, or a function that would take an array, list of field names, and process the list of names. This function would then be used by each category result box. Placing the function as a document level script would make this function available to the entire form. An assuming the values are assigned as follows: 5 = Exceeds Expectations, 4 = Very Good, 3 = Average, 2 = Below Average, 1 = Failing, and 0 = N/A, any question not selected, value of "Off", is not included in the computation. I assume you want to compute the average of responses for each category.

// document level function to compute and Averagefunction Average(aFields) {var fSum = 0; // sum of fieldsvar fCount = 0; // count of fields not "Off" // loop through the field namesfor(i = 0; i < aFields.length; i++) { if (isNaN(this.getField(aFields[i]).value) == false) {fCount++; // increment countfSum += Number(this.getField(aFields[i]).value)} // end if isNaN == false } // end loop of sum and count fields// compute the averagevar fAvg = 0;if (fCount != 0) fAvg = fSum / fCount;return fAvg;} // end Average function

For category 1 with names of "C0.Q#":

// custom calculation for the category average field// name of question radio buttons for categoryvar aFields = new Array("C0.Q0", "C0.Q1"); // array of field names to process event.value = Average(aFields); //field name "AvgC0"

For category 2 with names of "C1.Q#":
// custom calculation for the category average field// name of question radio buttons for categoryvar aFields = new Array("C1.Q0", "C1.Q1"); // array of field names to process event.value = Average(aFields); //field name "AvgC1"

For category 3 with names of "C2.Q#":
// custom calculation for the category average field// name of question radio buttons for categoryvar aFields = new Array("C2.Q0", "C2.Q1"); // array of field names to process event.value = Average(aFields); //field name "AvgC2"
caliboyoc wrote:
Questions 2 -
Is there a way to weight each category accordingly? For example, if I want the rep's greeting to be 10% of the overall score and their closing to be 50% and the friendliness to be 40% over the overall score, am I able to do that?
You multiply each category average by that categories weighting factor and sum the products.

// custom calculation for the weighted average of all categoriesfWgtAvg = 0; // weighted averagefWgtAvg += this.getField("Avg.C0").value * 0.10; // weighted average for category 1 fWgtAvg += this.getField("Avg.C1").value * 0.50; // weighted average for category 2fWgtAvg += this.getField("Avg.C2").value * 0.40; // weighted average for category 3

George Kaiser

RussellsRules
Registered: Dec 10 2007
Posts: 10
Thanks for the help!

I am very new to Java Script so bare with me. I am not exactly sure where to place each of the codes you sent.

I think I am supposed to label each category as follows:

Category 1: "C0.Q1"
Category 2: "C0.Q2"
Category 3: "C0.Q3" and so on...

Is that correct?

Where do I place the code this code:

// custom calculation for the category average field
// name of question radio buttons for category
var aFields = new Array("C0.Q0", "C0.Q1"); // array of field names to process

event.value = Average(aFields); //field name "AvgC0"

You gave me the code for each category, so I wasn't sure if I am supposed to place it in the radio button or a new text box.

I also wasn't sure where to place this code:

// document level function to compute and Average
function Average(aFields) {
var fSum = 0; // sum of fields
var fCount = 0; // count of fields not "Off"

// loop through the field names
for(i = 0; i < aFields.length; i++) {if (isNaN(this.getField(aFields[i]).value) == false) {
fCount++; // increment count
fSum += Number(this.getField(aFields[i]).value)
} // end if isNaN == false

} // end loop of sum and count fields
// compute the average
var fAvg = 0;
if (fCount != 0) fAvg = fSum / fCount;
return fAvg;
} // end Average function

I apologize for my inexperience with this and appreciate all the help I can get.

Thank you,

Russell