5 Replies Latest reply on Sep 26, 2017 9:37 AM by thesonofdarwin

    Add Field and Immediate Add Text

    thesonofdarwin

      Hello,

       

      I have a sequence of scripts I'm using to create copies of a page based on number of copies requested by the user (TotalPages). Subsequent to that I am running a script to rename all of the copied fields to a unique field by recreating the field name to stop sharing data entered into the field. Both of these scripts run fine for their intended purpose. However, I would like to at the same time as renaming the field to enter the page value before moving to the next field. I am new to JavaScript so I'm hoping someone can tell me what I'm doing wrong.

       

      This works for me:

       

      var TotalCopies = this.getField("TotalPages").value
      for (var i=0;i<TotalCopies;i++)
      {
      try{
      var rct=this.getField("CurrentPage."+i).rect;
      var pg=this.getField("CurrentPage."+i).page;
      this.addField("CurrentPg."+i,"text",pg,rct);
      }catch(e){break}
      }
      this.removeField("CurrentPage");
      

       

      When I tried to add entry of text (line 08) into the newly created field I couldn't get it to work. What I tried below:

       

      var TotalCopies = this.getField("TotalPages").value
      for (var i=0;i<TotalCopies;i++)
      {
      try{
      var rct=this.getField("CurrentPage."+i).rect;
      var pg=this.getField("CurrentPage."+i).page;
      this.addField("CurrentPg."+i,"text",pg,rct);
      this.getField("CurrentPg."+i).value = pg+1;
      }catch(e){break}
      }
      this.removeField("CurrentPage");