Copy link to clipboard
Copied
I have been attempting to calculate a subtraction javascript in acrobat X. (i am an inexperienced javascript coder and found part of this this in a search online. I made some assumptions and elaborated the rest)
This is my javascript:
// Get first field value
var v1 = getField("Qty Recd").value;
// Get second field value
var v2 = getField("Text4.0.1").value;
// Get third field value
var v3 = getField("Text4.1.1").value;
// Get fourth field value
var v4 = getField("Text4.2.1").value;
// Get fifth field value
var v5 = getField("Text4.3.1").value;
// Get sixth field value
var v6 = getField("Text4.4.1").value;
// Get seventh field value
var v7 = getField("Text4.5.1").value;
// Get eighth field value
var v8 = getField("Text4.6.1").value;
// Get ninth field value
var v9 = getField("Text4.7.1").value;
// Get tenth field value
var v10 = getField("Text4.8.1").value;
// Get eleventh field value
var v11 = getField("Text4.9.1").value;
// Set this field value equal to the difference
event.value = v1-v2;-v3;-v4;-v5;-v6;-v7;-v8;-v9;-v10;-v11;-v12;-v13;-v14
When I test the calculation, initially the result is correct. However, when I change one of the values to another number or delete it, the result continues to subtract what was initially entered in the field. How do I correct this? .
I have been trying different things and searching for help for two days.
Can anyone figure out what I am doing wrong? And then help me correct it?
Thank you Emelone
Copy link to clipboard
Copied
I thank you both for your attempt to help. I will look elsewhere for a solution since I do not seem to be able to get the answer here.
Copy link to clipboard
Copied
You need to make two changes:
You need to change line #4 and take the space out of the field name.
You need to change the last line and take out the extra ";' and add only one ';' at the end (you've had it correct in one of your previous replies: Re: Subtraction from multiple fields result is incorrect. )
Copy link to clipboard
Copied
Karl,
Your continued support is appreciated. I have tried all your suggestions, even your last one with no success. (You did receive an obsoleted file with that last line of javascript incorrect, that was in error) I sense frustration and suspect it is due to my inability to comprehend your instructions. You have made what appears to be a thorough attempt. I know nothing about javascript and some of your instructions are foreign to me. This turned out to be way more intimidating than I expected.
Thank you once again,
Eileen
Copy link to clipboard
Copied
You got a direct answer multiple times already. I tried to steer you in the right direction, but that seems useless.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now