2 Replies Latest reply on May 8, 2016 8:31 AM by gkaiseril

    Multiple if statements

    Nsmjc

      I am using this javascrpit which works well

       

      if (this.getField("CheckBox2").isBoxChecked(0)=="1")

      {event.value=this.getField("ofTrainingDays").value*10.00;} else event.value = 0;

       

      if (event.value==0)

      1. event.value="";

       

      I need to add a statement to the start of it to check the status of check box 3.   So if checkbox 3 is checked then the rest of the formula will be ignored and the "ofTrainingDays" will have a value of 0.

       

      if (this.getField("CheckBox3").isBoxChecked(0)=="1")

      {event.value=this.getField("ofTrainingDays").value0;} else

      if (this.getField("CheckBox2").isBoxChecked(0)=="1")

      {event.value=this.getField("ofTrainingDays").value*10.00;} else event.value = 0;

       

      if (event.value==0)

      1. event.value="";

       

      However this does not work correctly any Ideas

        • 1. Re: Multiple if statements
          JR_Boulay Adobe Community Professional

          Hi.

           

          In this case there is no need to get the value of a checkbox, it's checked or not.

          Try this :

           

          if (this.getField("CheckBox3").isBoxChecked(0)) {

              event.value = this.getField("ofTrainingDays").value;

              }

          else if (this.getField("CheckBox2").isBoxChecked(0)) {

              event.value = this.getField("ofTrainingDays").value * 10;

              }

          else {

               event.value = "";

               }

          1 person found this helpful
          • 2. Re: Multiple if statements
            gkaiseril MVP & Adobe Community Professional

            Since the field will either have the calculated value or a null string as a result, one can default the field value to a null string and then only set the field's value if the boxed is checked. I prefer to use the value of the check box in case the form is changed to have 2 check boxes for this item. An unslelected check box will have a value of "Off" so any value not equal to "Off" means the box has been checked.

             

            event.value = "";

            if (this.getField("CheckBox3").value  != "Off")  {

                event.value = this.getField("ofTrainingDays").value;

                }