8 Replies Latest reply on Nov 29, 2016 9:01 AM by Killnugget

    Iterate Through Fields and Delete based on Value in a Field




      I have a PDF form, one of many that I am using this script on.  For some reason it does not work correctly on this one document.


      There are fields at the bottom of each page which are populated with the text "<<remove_page>>" when I want the page to be deleted.  Here is the javascript I'm using attached to a button at the top of the first page:


      for (var fieldNumber = 0; fieldNumber < numFields; fieldNumber ++)


          var strfield  =   getField(getNthFieldName(fieldNumber)).value ;

          var strpage = getField(getNthFieldName(fieldNumber)).page ;

          if  (strfield == "<<remove_page>>") {





      The behavior is this.  It deletes all the pages but one.  It's the same one each time I have renamed the field, recreated it and moved the page around.   It leaves the page each time.  When I run the script from the button a second time it deletes the page.


      I tried debugging it and found that on the first run of the script it is not finding the field when it iterates through them.  The second time it does!!


      Any help would be great.  Thanks,