Copy link to clipboard
Copied
Hello,
I have no javascript experience at all; I need to create a Custom Calculation Script on my .pdf form to get it to do what I want.
i have ten field created that are named;
DIAL DOWN LESS 24,
DIAL UP LESS 24,
RATE 3H,
RATE 6H,
RATE 9H,
RATE FULLWIND,
RATE FULLWIND1,
RATE FULLWIND2,
RATE FULLWIND3,
RATE FULLWIND4
every field may have diferent value, negative or positive. its depence on the input;
example:
+1
-2
+3
+4
+1
+3
+1
+2
+1
+2
now what i want to get the result, is the variation of the minimum and the maximum of ten field:
from this example input is; minimum is -2 and the maximum is +4, the result should be 6. no positve or negative sign
example: +1 and +3 = 2
-4 and -1 = 3
-4 and +3 = 7
0 and +4 = 4
-4 and 0 = 4
If anyone can assist in helping me create a working Custom calculation script, it would be much appreciated.
thanks in advance.
looknbcool
[Question moved to the Acrobat forum. -Mod.]
Copy link to clipboard
Copied
You can use this code as the custom calculation script of your total field:
var fields = ["DIAL DOWN LESS 24", "DIAL UP LESS 24", "RATE 3H", "RATE 6H", "RATE 9H", "RATE FULLWIND", "RATE FULLWIND1", "RATE FULLWIND2", "RATE FULLWIND3", "RATE FULLWIND4"];
var values = [];
for (var i in fields) {
var f = this.getField(fields[i]);
var v = Number(f.valueAsString);
values.push(v);
}
values.sort(function(a, b){return a - b});
var minValue = values[0];
var maxValue = values[values.length-1];
event.value = maxValue-minValue;
Copy link to clipboard
Copied
try67
Awesome! This did it! Thank you!
looknbcool
Copy link to clipboard
Copied
hello try67
i did some testing and the code wont run at all, like when i use acrobat reader on iphone.
any idea how to fix it?
Copy link to clipboard
Copied
Scripts are generally not supported on mobile devices, sorry.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more