4 Replies Latest reply on May 16, 2017 6:03 AM by davidp84650061

    New page woes!!

    davidp84650061

      Hi,

       

      I am using a template to add pages to a document which works fine. I have some (48) field calculations to check a box if an input value is between a certain range. It works fine on page 1. I know it is not working because the field names in the calculation do not change with the new field names generated with the new page.

       

      Here is the script I am using on Page 1:

       

      var drop = this.getField.("InputText7");

      var check = this.getField.("CheckBox1");

      if(drop.value >= '0' && drop.value <= '0.25'){

      check.checkThisBox(0,true);

      }

      else{

      check.checkThisBox(0,false);

      }

       

      Is there a way to use this page and a field containing a part of the name in the calculation as going forward the fields on all the pages will contain "InputText7" and "CheckBox1" but with P1 and the name of the template added to it etc.

       

      I am using Adobe Acrobat Pro.

       

      Thanks in Advance.

       

      David.

        • 1. Re: New page woes!!
          try67 MVP & Adobe Community Professional

          - Drop the dot after getField, before the parentheses.

          - Drop the quotes around the numbers in the if-conditions.

          1 person found this helpful
          • 2. Re: New page woes!!
            davidp84650061 Level 1

            Sorry about that, copy and paste error.

             

            I have tried to use the endsWith function but to no avail!!

             

            var drop = this.getField.endsWith("InputText7");

            var check = this.getField.endsWith("CheckBox1");

            if(drop.value >= 0 && drop.value <= 0.25){

            check.checkThisBox(0,true);

            }

            else{

            check.checkThisBox(0,false);

            }

             

            Am I on the right track?

            • 3. Re: New page woes!!
              try67 MVP & Adobe Community Professional

              The first two lines should simply be:

              var drop = this.getField("InputText7");

              var check = this.getField("CheckBox1");

              • 4. Re: New page woes!!
                davidp84650061 Level 1

                Ok, I have that and it works on page 1 (the original) which I have converted into the template. I have an Add New Page button which adds the new page no problem. All of the fields populate with the new page number and the template title i.e. 'P1.Template.InputText7' and so on. The issue is that the values within the custom calculation script stay the same which would be a given. Is there a way to write the code so that it looks and the active page and the common denominator i.e. 'InputText7' and 'CheckBox1' which will be on all pages and run the calculation from there. In the code above I tried the 'endsWith()' function and i have also tried the 'includes()' function. Do these functions only work when looking at a string or can they be used to look at a field name? Are the numbers in the field name affecting the code? I would like to put this code into the original document so that the template will be based on the same custom calculation script. Thanks again for your help.