Skip to main content
Participant
March 2, 2023
Question

Help with showing an average results as a letter

  • March 2, 2023
  • 1 reply
  • 611 views

I have no experience with Java script, but we want to be able the average results of our to show as a letter.

For example, Rating: Above Target can equal 3, On Target = 2, Below Target =1.

We want the average of those ratings to show at the bottom of the form as a letter.

So if the average is between 2 and 2.5, then it should be OT(on target), if <2.6 then Above Target, etc. 

I see there's an option for custom calculation, but not sure what to add. Thanks in advance

 

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
March 3, 2023

You'll need to use a script in the custom calculation for the average.

This script assumes the calculation is done in the same field that shows the letters. 

Also, the calculation is not shown, because that part is up to you. 

(On another note, your rule that  "Above Target" is when the ave<2.6 doesn't fit with the first condition.)

var nAverage = ... some calculation ...;

if((nAverage >=2) && (nAverage <= 2.5))
   event.value = "OT";
else if((nAverage >2.5) && (nAverage <= 3.0))
   event.value = "somethign else";
else
  event.value = "N/A";

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often