Skip to main content
marie@fogmaker
Participating Frequently
January 29, 2019
Answered

Need help with simple(?) calculation please

  • January 29, 2019
  • 1 reply
  • 532 views

Hello

I have an interactive pdf form where my simple calculation doesnt get the correct answer - sometimes no answer at all?

A= number input by user

B= number input by user

V= A*B

so far so good, then:

C= number input by user

D= 0.8 1.2 3.5 (drop down list)

     0.8 generates export value 0.7

     1.2 generates export value 1.0

     3.5 generates export value 2.3

Q= product of C and respective exported value ------ this value is sometimes 0?

T=V/Q*60  -----this is the final value which I never seem to get right

This topic has been closed for replies.
Correct answer Bernd Alheit

This is the calculation for T:

var volume = this.getField("V")

var flow = this.getField("Q")

if (flow.value==0) event.value = "";

else event.value = ( volume.value / flow.value ) * 60


Did you check the field calculation order?

1 reply

try67
Community Expert
Community Expert
January 29, 2019

If Q is zero then you can't calculate a value for T, as division by zero is not allowed.

You must therefore use a script for T's calculation event, checking first if Q is zero. If so, apply an empty value to it.

If not, proceed with the calculation.

marie@fogmaker
Participating Frequently
January 29, 2019

I understand that but Q should never be zero.  Q must equal product of C and respective exported value - but sometimes the product is not calculated.

Now when I filled it in again I got Q but not T...

marie@fogmaker
Participating Frequently
January 29, 2019

This is the calculation for T:

var volume = this.getField("V")

var flow = this.getField("Q")

if (flow.value==0) event.value = "";

else event.value = ( volume.value / flow.value ) * 60


Now I got value for T ...Is this a bug?

Also,

If I keep D the same (in this case D=1.2 which generates 1.0) and only change C.

I get different values for T...

  • C=6-->Q=6-->T=51sec should be 60 sec....
  • C=7-->Q=7-->T=60sec (unlogical...)
  • C=8-->Q=8-->T=51sec (unlogical...)
  • C=9-->Q=9-->T=45sec (what I mean is that the time should decrease as C increases...)

then I try C= 6 again:

  • C=6-->Q=86->T=40sec (???? unlogical...) should be 60 sec....