2 Replies Latest reply on Apr 27, 2014 9:21 AM by MatLac

    "Pushing values to the left"

    MatLac Level 1

      I have 4 textfields and I want to make sure they are filled from left to right.  I created the following script:

       

      var mipField = ["OPE003.EVEN.1.MIP", "OPE003.EVEN.2.MIP", "OPE003.EVEN.3.MIP", "OPE003.EVEN.4.MIP"];
      var cItem = ""
      var mipArray = new Array();

       

      //Creating an array of "not null" values from fields
      for ( i = 0; i < mipField.length; i++){
          cItem = this.getField(mipField[i]).valueAsString;
          if (cItem != ""){
              mipArray[mipArray.length] = cItem;
          }
      }


      //Emptying the fields
      for ( i = 0; i < mipField.length; i++){
          this.resetForm(mipField[i]);
      }


      //Copying values from the array to the fields
      for ( i = 0; i < mipArray.length; i++){
          this.getField(mipField[i]).value = mipArray[i];

      }

       

      for some reason I get an "invalidSetError" from that calculate script, when it comes to the copying part.  I don't undestand what the problem is.

        • 1. Re: "Pushing values to the left"
          try67 MVP & Adobe Community Professional

          First of all, you're not using resetForm correctly. It takes as a parameter

          an array of strings, not a string.

          So you can simply call it like so:

          this.resetForm(mipField);

          1 person found this helpful
          • 2. Re: "Pushing values to the left"
            MatLac Level 1

            I changed the code to:

             

            var mipField = ["OPE003.EVEN.1.MIP", "OPE003.EVEN.2.MIP", "OPE003.EVEN.3.MIP", "OPE003.EVEN.4.MIP"];
            var cItem = ""
            var mipArray = new Array();

            //Creating an array of "not null" values from fields
            for ( var i = 0; i < mipField.length; i++){
                cItem = this.getField(mipField[i]).valueAsString;
                if (cItem != ""){
                    mipArray[mipArray.length] = cItem;
                }
            }

             

            this.resetForm(mipField);

            for ( var i = 0; i < mipArray.length; i++){

                this.getField("OPE003.EVEN."+(i+1)+".MIP").value = mipArray[i];

             

            and moved it to the blur event instead of the calculate event.  I guess looping a script changing values inside a calculate event was the problem since the calculate event is triggered by changing values.  It must have caused a circular patern.  It works now.