0 Replies Latest reply on Mar 27, 2014 1:04 PM by F0084r

    Custom Calculation Script almost works...


      I'm trying to creaet a form that uses a dropdown box to select the proper text for a text field.  I have created the form and the Custom Calculation for my Text box works great (Thanks to these forums!).


      The problem I am experincing now is that I want to be able to use an Add Page button to spawn another blank copy of the form within the file.  The page spawns correctlly (Once again thanks to these forums!), but My text fields in all of the pages only have the calculated value based upon the last page added.


      Here is my script to spawn the page based upon a template called "Additional Information":


      var a = this.getTemplate("Additional Information");




      resetFieldsOnPage() is a document level javascript that is used to clear the form when it spawns and also to clear and indvidual page with the use of a Clear Button:


      function resetFieldsOnPage(p)


      var fields = [];

          for (var i=0; i<this.numFields; i++) {

              var f = this.getField(this.getNthFieldName(i));

              if (f==null) continue;

              if (f.page==p)






      My Text field with the custom calaculation script looks like this:


      //var v = this.getField("Dropdown2").value;



      var v;

      var p = "P";

      var pagecount = this.pageNum;

      var AI= ".Additional Information.";

      var drop = "Dropdown21";


      var Value1013A = "VALUEA";

      var Value1013B = "VALUEB";

      var Value1013C = "VALUEC";

      var Value1013D = "VALUED";

      var Value1013E = "VALUEE";

      var Value1013F = "VALUEF";

      var Value1013G = "VALUEG";

      var Value1013H = "VALUEH.";

      var Value1015A = "VALUE105A";


      if (pagecount == "0") v = this.getField(drop).value;

          else v = this.getField(p+pagecount+AI+drop).value;


      if (v=="101-3 subd.A") this.event.value = Value1013A;

           else if (v=="101-3 subd.B") this.event.value = Value1013B;

           else if (v=="101-3 subd.C") this.event.value = Value1013C;

           else if (v=="101-3 subd.D") this.event.value = Value1013D;

           else if (v=="101-3 subd.E") this.event.value = Value1013E;

           else if (v=="101-3 subd.F") this.event.value = Value1013F;

           else if (v=="101-3 subd.G") this.event.value = Value1013G;

           else if (v=="101-3 subd.H") this.event.value = Value1013H;

           else if (v=="101-5 subd.A") this.event.value = Value1015A;

           else this.event.value = " ";


      I can add pages succesfully with the ADD PAGE button and the additional forms are blank.  As soon as I select a Value in dropdown21 on the new page, All the text boxes that have the above custom calcualtion script change to the value on the last page.  The last page is correct, but all the pages before it have changed.


      I have made sure that the form is blank before creating the template.  I have even exported a copy of the orginal page with no data in it and then imported it as a new page.  After the import I have changed all of the form field to completelly different names and then modified the script of the imported page before creating the template.  I just can't see the problem.  Any help is appreciated.  Thanks