2 Replies Latest reply on May 11, 2015 2:00 PM by gkaiseril

    custom calculation script

    LaceyjDay

          I am trying to perform this action:

       

      if box a is 351 to 450 then box b is equal to $6.50

      if box a is 451 to 1000 then box b is equal to $6.00

       

      is this possible?  If so any help would be greatly appreciated.

       

      Thank You in advance!

        • 1. Re: custom calculation script
          try67 MVP & Adobe Community Professional

          Sure, that's possible. But what if it's neither?

          • 2. Re: custom calculation script
            gkaiseril MVP & Adobe Community Professional

            One can use the "if else" statement or the "switch" statement to conditionally control the execution of blocks of code.

             

            Assuming you are using numeric fields name "a" and "b"

             


            // custom calculation script for field "b";
            var aValue = this.getField("a").value;
            if(aValue  >= 351 && aValue < 450) event.value = 6.5;
            else if(aValue >= 451 && aValue < 1000) event.value = 6.;
            else event.value = 0;

             

            // or;

            // custom calculation script for field "b";
            var aValue = this.getField("a").value;
            switch(true){
            case (aValue  >= 351 && aValue < 450) :
            event.value = 6.5;
            break;
            case (aValue >= 451 && aValue < 1000) :
            event.value = 6.;
            break;
            default:
            event.value = 0;
            break;
            }