1 Reply Latest reply on Nov 6, 2014 10:43 PM by George_Johnson

    Conditional Statements in Javascript

    Kevin KPS

      I am creating a form using PDF pro 9 I need help with calculating a value for a rebate with solar

      The value calculated in another part of the form Is called TSRF

      and the SystemSize is calculated based on input also on the form of the number of solar panels * wattage.

      The condition is if the TSRF is less than < 80% then       SystemSize  * .40 * TSRF (this is a derated amount because TSRF is below 80)

      If the TSRF Is 80% or greater than     SystemSize * 40 (Not derated because TSRF is above 80)

       

      Thanks

        • 1. Re: Conditional Statements in Javascript
          George_Johnson MVP & Adobe Community Professional

          The custom calculation script could look something like this:

           

          // Custom calculation script for text field

          (function () {

           

              // Get the field values, as numbers

              var TSRF = +getField("TSRF").value;

              var SYS_SIZE = +getField("SystemSize").value;

           

              // Calculate rebate, rounded to two decimals

              if (TSRF < 80) {

                  event.value = util.printf("%.2f", 0.4 * SYS_SIZE * TSRF);

              } else {

                  event.value = util.printf("%.2f", 40 * SYS_SIZE);

              }

           

          })();