Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

making custom calculation script.

New Here ,
Oct 20, 2019 Oct 20, 2019

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.]

372
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 22, 2019 Oct 22, 2019

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;
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 22, 2019 Oct 22, 2019

try67

Awesome! This did it! Thank you!

looknbcool

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 24, 2019 Oct 24, 2019

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 25, 2019 Oct 25, 2019
LATEST

Scripts are generally not supported on mobile devices, sorry.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines