Copy link to clipboard
Copied
Hi, I'm hoping someone can help me urgently on this one...
I have the following formula in excel, but not sure how to change it so it works as Java in the custom calculation field in Acrobat (I've used some online tools but none seem to work).
JS wise, this where I've got to....not very far:
There'll be a number of 'FINALscoreS#' fields (yet to be decided). and what I'm after is:
The sum of all results in the 'FINALscoreS#' fields, divided by the sum of 13*however many 'FINALscoreS#' have a value (even if that value is zero...so ignoring any blanks).
(And then multiplied by 100 to give a percentage - the excel formula works perfectly if that's any use)
Does that makes sense? Can anyone help?? Pretty sure there'll be an array involved somewhere...
Huge thanks in advance...I expect for a JS guru this is as simple as 2+2, apologies!!
🙂
Hi,
Try that and let me know if I didn't understand someting.
var nb=numberOfFields;
var theSum=0;
var noBlank=0;
for (var i=1; i<=nb; i++) {
theSum+=Number(this.getField("FINALscoreS"+i).value);
if (this.getField("FINALscoreS"+i).valueAsString!="") noBlank++;
}
event.value=theSum*100/(13*noBlank);
@+
Copy link to clipboard
Copied
Hi,
Try that and let me know if I didn't understand someting.
var nb=numberOfFields;
var theSum=0;
var noBlank=0;
for (var i=1; i<=nb; i++) {
theSum+=Number(this.getField("FINALscoreS"+i).value);
if (this.getField("FINALscoreS"+i).valueAsString!="") noBlank++;
}
event.value=theSum*100/(13*noBlank);
@+
Copy link to clipboard
Copied
Hi Bebarth,
Thanks so much for answering.
Unfortunately I'm only getting a result of 0, no matter what value is in the 'FINALscoreS#' fields.
Reading the code (from my limited understanding) it looks like you've understood what I'm after, it's just not working as it should...Thanks again for trying to help, it's hugely appreciated 🙂
P.S. The fields are on separate pages...that didn't used to make any difference as far as a I remember, but thought I'd mention it just in case.
Copy link to clipboard
Copied
ooooh...the "FINALscoreS" fields are calculated fields. They work fine as it's simple x+x...would that matter?
Thanks again
Copy link to clipboard
Copied
Copy link to clipboard
Copied
aaah!!! FANTASTIC! I understand now, I needed to add the variable number. My mistake, i didn't get that.
This is perfect!! Thanks so much for your help. You have no idea how much I appreciate it 🙂
Thanks so again! 🙂 🙂 🙂 🙂 🙂 🙂 🙂
Copy link to clipboard
Copied
Dear Adobe, our company starts blocking java scripts in Adobe (Reader and Pro) how you use calculation fields after that? What is the alternative to javascript? How can these fields be used afterwards?
Copy link to clipboard
Copied
There is no alternative. If JS is disabled calculations will not work.