Copy link to clipboard
Copied
Hello everyone,
I need help with an Adobe Form. I'm pretty new to Adobe, so please be kind.
I have created an Performance Evaluation Form for work, with different sections, each section has a total sum. Now I need to calculate an average rating of that total. (see below)
As you can see the calculation is not correct, 57/ 36 = 1.58 NOT 1.76!
Also, I need to account if we only have 33 fields filled instead of 36. So account for "0" or blank fields.
This is the code I got from someone. I'm not sure why is not working. (see below)
var pG = this.getField("SUPERVISOR PRIOR YR SKILLS GOAL #34").value;
var RT = this.getField("RATING TOTAL").value;
var fAR = ((RT/36));
var hAR = ((RT/33));
if (pG == 0) event.value=((hAR));
else event.value=((fAR));
If anyone could, please help!
Copy link to clipboard
Copied
Hi there, anyone see a mistake in the code posted?
Copy link to clipboard
Copied
You will need to share the file for help with this, as the code looks fine.
If you want to ignore empty fields you can use a function to go over all the fields you want to add up, and check their values first. If they are not empty, add their value to the total and increment a counter by one.
At the end, divide the total by the counter, if the latter is not zero.
I've posted code that does just that multiple times here. Search the forum for "calcAverage".
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Check the JS Console. There are errors in your code.
Copy link to clipboard
Copied
Hi, could you be specific about the errors? How do I fix it?
Copy link to clipboard
Copied
Open the JS Console (Ctrl+J) and you'll see them for yourself.
What I see is this:
TypeError: this.getField("SUPERVISOR PRIOR YR SKILLS GOAL #34") is null
1:Field:Calculate
It's possible in your version it will not show the field name, though.
What this means is that you've specified the wrong field name in that line.