2 Replies Latest reply on Nov 20, 2012 12:00 PM by DarthAngelus

    Custom Form Calculation

    DarthAngelus

      Hello All,

       

      I am creating a custom form and need a very specific calculation in one of my form fields but can't seem to get it down.

       

      I need the field to choose the greater value of two other fields, but if a checkbox is checked I need the field to be 0.

       

      So, in short I need something akin to:

       

      If Check 1 = ON, Field 1 = 0 else Field 1 = greater of Field 2 and Field 3

       

      Can someone help me out?

       

      Thanks!

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

          Do you have any programing experience with object orientated languages?

           

          You need to get the object you want to work with and then use the object's properties or methods.

           

           

          var Check1 = this.getField("Check 1"); // get the field object for field Check 1

          app.alert("Check 1 has a value of: " Check1.value); // show the value of Check 1 field

           

          Check boxes have the value of the "Export value" option when selected. If not selected the value is the string "Off".

           

          If you are putting the calculation in the form field, until you exit that field, you use "event" for that field's object

           

          var Check1 = this.getField("Check 1"); // get the field object for field Check 1

          app.alert("Check 1 has a value of: " Check1.value); // show the value of Check 1 field

          event.value = 0; // default value

          if (this.getField("Check 1").value != "Off")

          event.value = Math.max(this.getField("Field 2").value, this.getField("Field 3").value); // get greater value

          • 2. Re: Custom Form Calculation
            DarthAngelus Level 1

            Thanks! Worked like a charm... However it works backwards when used like this. Curiouser and curiouser...

             

            Oh well. Point is, I got it working. Thanks again!