Skip to main content
Participating Frequently
February 1, 2017
Question

Subtraction from multiple fields result is incorrect.

  • February 1, 2017
  • 28 replies
  • 2289 views

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

This topic has been closed for replies.

28 replies

Karl Heinz  Kremer
Community Expert
Community Expert
February 1, 2017

This line is not correct:

event.value = v1-v2;-v3;-v4;-v5;-v6;-v7;-v8;-v9;-v10;-v11;-v12;-v13;-v14

What exactly do you want to calculate?

EGMelone7Author
Participating Frequently
February 1, 2017

The ("Qty Recd") field is a number of total pounds

there are 14 other fields each of which may contain a reject number of weight

I want each of those fields (when they contain a number) to be subtracted from the total pounds.