7 Replies Latest reply on Oct 11, 2013 5:30 AM by try67

    Variables

    grahamsarah3 Level 1

      I am trying to create a script in my Acrobat XI form where if the sum of the fields "Bolus1LPMAverage" + "Bolus2LPMAverage" + "Bolus3LPMAverage" is between the range of 59.35 and 60.65 then a check box "PASS" will automatically select, but if this sum is less than 59.35 or more than 60.65, the check box "FAIL" will check automatically.

       

      There are about 10 fields that add up to get the Bolus Averages in 3 different columns. When I have tried to even start this, with the tiny bit of script I know, it says my field is not in range. Please help if you can,

        • 1. Re: Variables
          try67 MVP & Adobe Community Professional

          You can't use the built-in Range Validation option when using such a script. You have to allow all values and use your script to validate the calculated sum and based on it check the appropriate box.

          • 2. Re: Variables
            grahamsarah3 Level 1

            Ok so if the Average of Bolus 1 falls in the range of 9.85 and 10.15, how do I get the box to check automatically? That's what I keep running up against

            • 3. Re: Variables
              grahamsarah3 Level 1

              Or can I have it take the value of another field and verify that it is within the range I desire?

              • 4. Re: Variables
                try67 MVP & Adobe Community Professional

                You can use a custom validation script. Something like:

                 

                var v = Number(event.value);

                if (v>=59.35 && v<=60.65) {

                     this.getField("PASS").checkThisBox(0, true);

                     this.getField("FAIL").checkThisBox(0, false);

                } else {

                     this.getField("PASS").checkThisBox(0, false);

                     this.getField("FAIL").checkThisBox(0, true);

                }

                 

                (Edit: I used the values from your original post. You can change them, of course.)

                • 5. Re: Variables
                  grahamsarah3 Level 1

                  THANK YOU!!! Worked like a charm!

                  • 6. Re: Variables
                    grahamsarah3 Level 1

                    One more thing, if I want to do the same thing in another field, same document, using the script you previously shared, would it look like this? I am naming my secondary fields Numbers2 and check boxes PASS2/FAIL2 if that makes sense:

                    var v = Number2(event.value);

                     

                     

                    if (v>=19.80 && v<=20.20) {

                     

                         this.getField("PASS2").checkThisBox(0, true);

                     

                         this.getField("FAIL2").checkThisBox(0, false);

                     

                    } else {

                     

                          this.getField("PASS2").checkThisBox(0, false);

                     

                          this.getField("FAIL2").checkThisBox(0, true);

                     

                    }

                    • 7. Re: Variables
                      try67 MVP & Adobe Community Professional

                      No. Number() is a built-in constructor function that attempts to convert a variable of any kind to a Number variable.

                      There's no such thing as Number2()...