1 Reply Latest reply on Jun 6, 2012 2:48 PM by gkaiseril

    Calculation help

    jezza987

      Hi, hope you can help me!

       

      I need to calculate an if/and/or statement for a field.

       

      The calculation first grabs the value of a field (Total Amount2) then uses a condition statement, which is:

       

      If TotalAmount2 equals 0-100 (than TotalAmount2 multiplies by 8)

       

      -or- If TotalAmount2 equals 101-300 (than TotalAmount2 multiplies by10)

       

      -or- If TotalAmount2 equals 301-1000 (than TotalAmount2 multiplies by .045)

       

      -or- If TotalAmount2 equals 1001-2500 (than TotalAmount2 multiplies by .02)

       

       

      Any help would be greatly appreciated and much karma will be sent your way!

       

      Thanks!

        • 1. Re: Calculation help
          gkaiseril MVP & Adobe Community Professional

          var nTotalAmount = this.getField("TotalAmount2").value;
          var nRate = 0;

          switch(true) {
          case (nTotalAmount >= 0 && nTotalAmount < 101) :
          nRate =  8;
          break

          case (nTotalAmount >= 101 && nTotalAmount < 301) :
          nRate = 10;
          break

          case (nTotalAmount >= 301 && nTotalAmount < 1001) :
          nRate = 0.045;
          break

          case (nTotalAmount >= 1001 && nTotalAmount < 25001) :
          nRate = 0.02;
          break

          default:
          app.alert("Total Amount 2 is outside of limits", 1, 0);
          nRate = 0;
          break;
          }
          event.value = nTotalAmount * nRate;

           

          Make sure your field names are spelled and capitalize correctly.