4 Replies Latest reply on Nov 21, 2016 11:52 AM by Zafu

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

    Zafu

      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.

        • 1. Re: I need help with a formula or java script for Acrobat 11
          gkaiseril MVP & Adobe Community Professional

          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");

          • 2. Re: I need help with a formula or java script for Acrobat 11
            Zafu Level 1

            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  

            • 3. Re: I need help with a formula or java script for Acrobat 11
              gkaiseril MVP & Adobe Community Professional

              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.

              1 person found this helpful
              • 4. Re: I need help with a formula or java script for Acrobat 11
                Zafu Level 1

                Thanks again for your help.  I was able to achieve what I wanted by creating another field that I used to subtract B from A and then I used the following script in the Custom JavaScript Calculator, which solved my issues.  Thanks for your help.

                 

                var AirValue = this.getField("Air").valueAsString;

                if (AirValue=="") event.value = "";

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

                if (AirValue<=0) event.value = "";

                else event.value = (Number(AirValue));

                if (AirValue=="") event.value = "";

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

                if (AirValue<=0) event.value = "";