1 Reply Latest reply on Oct 11, 2016 10:00 AM by CalicoCat5000

    Hide Zero only part of the time

    CalicoCat5000

      Hello, I’ve created a pdf that might be used on the computer, but others might also print it and handwrite their information on the form.  I need a zero to appear when the event value is zero, and for the field to be blank when nothing has yet been entered.

      The three pertinent fields are named Value, RoundedValue and Fee.

       

      In the RoundedValue field Custom Calculation Script I have:

      var v1 = this.getField("Value").value;

      event.value = Math.floor(v1/ 1000) * 1000;

       

      A zero always shows in the RoundedValue field unless a user enters numbers in the Value field.  The RoundedValue must actually be blank until a user enters numbers in the Value field.  If they enter less than 1,000 in the Value field, only then should the RoundedValue field show a 0.

       

      In the Fee field Custom Calculation Script the closest I’ve gotten to my goal is:

      var v2 = this.getField("RoundedValue").value;

      var total = v2 * .001;

      if (total !==0){event.value = total} else {event.value = ""}

       

      The Fee field is blank until a user enters a number in the Value field, but the Fee field does not show a 0 when users enter less than 1,000 in the Value field.  The Fee field has to actually show a 0 when the Value field is less than 1,000.

       

      Any help would be appreciated. Thanks.

        • 1. Re: Hide Zero only part of the time
          CalicoCat5000 Level 1

          I found the answer on a different forum, just wanted to share.

           

          In the RoundedValue field Custom Calculation Script I have:

          var v1 = this.getField("Value").value;

          event.value = Math.floor(v1/ 1000) * 1000;

          if ((event.value == 0) && (getField("Value").valueAsString === "")) event.value = "";

           

          In the Fee field Custom Calculation Script I have:

          var v2 = this.getField("RoundedValue").value;

          event.value = v2 * .001;

          if ((event.value == 0) && (getField("Value").valueAsString === "")) event.value = "";