Skip to main content
November 20, 2016
Question

I need help with a formula or java script for Acrobat 11

  • November 20, 2016
  • 1 reply
  • 317 views

I am trying to subtract two number fields and show the result in a third field.  However, if the result is less than or equal to zero, I want the third field to be blank.

If I have fields A, B and C, I want C to show the result of A minus B.  But, if A minus B is less than or equal to zero, I want C to be blank. 

I am using Acrobat Pro 11 on a Mac computer. 

Thanks in advance for your help.

This topic has been closed for replies.

1 reply

Inspiring
November 20, 2016

One can logically combine 2 or more simpler logical statements into a more complex logical statement.

var A = 1;
var B = 0;
if( (A > 0) && (B > 0) )
app.alert("True");
else app.alert("False");

November 20, 2016

Thanks for the response but I don't really understand how to apply your statements.  I have to subtract A from B but don't want numbers equal to or less than zero to show because they are not relevant to my needs. 

Field A has this simple formula in it (A/1000)*50.  'A' is the BTUH input of a combustion appliance.  The formula calculates the required volume of air to supply the combustion appliance. 

Field B is the volume of the room the appliance is located in. 

Field C is the result of subtracting B from A.  If the result is positive it is the amount of make up air required.  If the result is zero or negative there is enough air and nothing needs to be done.  Therefore, I want Field C to be blank when the result is zero or less.  If the result is positive I need it to show so we know how much extra air we need. 

For example:  If A =120,000, Field A would show the result of 120,000/1,000*50 or 6,000.

                       Field  B = 5,000

                       Field  C = 1,000 

Field C must show the result because there is not enough air in the room.

But if Field B=6,500,  Field C would show -500.  I want this result to show in Field C as a blank because there is enough air and I don't want to confuse anyone with a result they might misread. 

So far the formula I have in Field C is just   A-B  

Inspiring
November 21, 2016

It appears you are using the "Simplified Field Notation" calculation option. You cannot us a number of statements, functions, properties, methods, etc that are available to Acrobat JavaScript. You need to create a Custom JavaScript Calculation to perform what you are asking for.