3 Replies Latest reply on Jun 10, 2015 7:47 AM by ahlaj77

# Average calculation script converting to letters (A, B, C, etc), not properly working

Shown above are examples. In the small purple boxes letters A, B, C, D, or F are placed. Each of them correspond to a number. A = 1, B = 2, C = 3, D = 4, and F = 5. Once all six boxes are filled out, the average is taken (which is shown as the very last number below the purple boxes). In the big black box a letter is shown based on the average. If the average is 1 display A, etc. Somehow when I go through the boxes and change letters, the calculation for the BIG LETTER is not calculating properly (see the right image). Please let me know if you can help! Thanks!!!

https://www.dropbox.com/s/rm2mxnzk513q6m3/Letter%20PDF.pdf?dl=0

• ###### 1. Re: Average calculation script converting to letters (A, B, C, etc), not properly working

Have you checked the JavaScript console for any errors?

Use the key combination of [Ctrl] + "J" to open the JavaScript console.

It appears your validation script for "Rate.0"  has an error.

Actually one can use the same script for the validation script since it is possible to compute the field name for each "RateCalc"

Try:

var cName = event.target.name;
var aName = cName.split(".");
var nIndex = aName[1]
event.rc = true;

if(event.value != "A" && event.value != "B" && event.value != "C" && event.value != "D" && event.value != "F" && event.value != "") {
app.alert("The entered value needs to be either 'A', 'B', 'C', 'D', or 'F'");
event.rc = false;
event.value = "";
this.getField("RateCalc." + nIndex).value = 0;
}

Have you computed any sample averages with paper and pencil?

If you have 3 A's and 3 B's the total would be 9 the number of items 6 and the average 1.5

The displayed value of the average has been rounded for display but the actual value of the field has not been rounded. You need to round the value of calculation.

• ###### 2. Re: Average calculation script converting to letters (A, B, C, etc), not properly working

Thanks for the input! I will give it a try and let you know!

• ###### 3. Re: Average calculation script converting to letters (A, B, C, etc), not properly working

Thank you for your help! Your code helped fix it! I appreciate it! Always helps to have a second pair of eyes to look at it.