1 Reply Latest reply on Aug 5, 2015 10:17 AM by try67

    HELP! If else statement

    or_girl

      I need help with the following form questions:

       

      Field 1: ConfHotelYorN

      Field 2: HotelRate

      Field 3: IRSMaxLoding

      Filed 4: EmpCost

       

      If the person answers "Yes" to the question in Field 1, nothing else needs to be done or  "0" could be put in Field 4

      If the person answers "No" to the question in Field 1, then if Field 2 is <= Field 3 then put "0" in Field 4

      if Field 2 is > Field 3 then value of Field 4 = Field 2 minus Field 3

       

      I have made multiple attempts and can't get it to work. Any help will be greatly appreciated.

        • 1. Re: HELP! If else statement
          try67 MVP & Adobe Community Professional

          Use this code as the custom calculation script of EmpCost:

           

          var v1 = this.getField("ConfHotelYorN").valueAsString;
          var v2 = Number(this.getField("HotelRate").valueAsString);
          var v3 = Number(this.getField("IRSMaxLoding").valueAsString);
          
          if (v1=="No") {
              if (v2<=v3) event.value = 0;
              else event.value = v2-v3;
          } else event.value = 0;