Skip to main content
Participating Frequently
April 3, 2020
Question

Search result adobe form

  • April 3, 2020
  • 1 reply
  • 640 views

 

Hi,
please help me solve my javascript problem. I'm not a specialist and I can't handle it.

I have in PDF form ex. four number fields. A, B, C, D.
Field A is the entrance. Fields B and C do calculations (ex. A+B+C). Field D=A+B+C this is the result.
Now I want to make an auxiliary field D1.
Script operation. After entering the D1 value, the script substitutes the A value, checks the calculations and the D result, and works until the D = D1 condition is met
Thank you for any tips.

Edit
I came to this solution, but the result is always 1 too big


for (var i=1;this.getField("D1").value!=this.getField("D").value;i++){
this.getField("D").value=this.getField("A").value+this.getField("B").value+this.getField("C").value
this.getField("A").value=this.getField("A").value+1
};

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
April 3, 2020

Change the first line to :

while (this.getField("D1").value!=this.getField("D").value) {

Participating Frequently
April 3, 2020

try67 Thank you, it works. I still have a problem with decimal numbers. At the moment I increase by 1 how to do it so that there are e.g. values of 3.56?

 

Edit:

I came to the solution (in bold) and it works for the result e.g. 3.50 but it does not work for the result e.g. 3.56 or 3.55

 

while (getField("D1").value!=this.getField("D").value){
this.getField("A").value=this.getField("A").value+=.1
this.getField("D").value=this.getField("A").value+this.getField("B").value+this.getField("C").value
};

try67
Community Expert
Community Expert
April 3, 2020

Add 0.01 instead of 0.1... There must be a better way to solve this issue then by brute-force, though.