2 Replies Latest reply on Oct 24, 2012 3:31 AM by MadMich

    page number and template

    MadMich Level 1

      Hi all,

      Since adding the page number and template name (HR) my script has stopped working?

      Can any one see where i am going wrong? The only bit that has changed is "("P"+j+".HR."+"X."+f)" when testing successfully all i had was ("X."+f).

       

       

      var j = this.pageNum;

       

      var f = event.target.name;

      global.FieldName=event.target.name;

       

      //name of template = HR

       

      var fieldValue = event.target.value;

      event.target.value = app.popUpMenu("CANCEL", "-", "Y", "N/A");

      if (event.target.value=="Y"){

           this.getField("P"+j+".HR."+"X."+f).fillColor = ["CMYK", 0, 0, 0, 0.3];

           this.getField("P"+j+".HR."+"X."+f).borderColor = ["CMYK", 0, 0, 0, 0.6];

      }else{

           var fieldValue = event.target.value;  }

      if (event.target.value=="N/A"){

           event.target.value = "";

           this.getField("P"+j+".HR."+"X."+f).fillColor = ["CMYK", 0, 0, 0, 0.3];

           this.getField("P"+j+".HR."+"X."+f).borderColor = ["CMYK", 0, 0, 0, 0.6];

      }else{

           var fieldValue = event.target.value;  }

      if (event.target.value=="CANCEL"){

           event.target.value = "";

           this.getField("P"+j+".HR."+"X."+f).fillColor = ["CMYK", 0, 0.1, 0.1, 0];

           this.getField("P"+j+".HR."+"X."+f).borderColor = ["CMYK", 0.1, 0.1, 0.1, 0.1];

       

      }else{

           var fieldValue = event.target.value;  }

      if (event.target.value=="null"){

           event.target.value = "";

           app.alert("Please enter a valid option, or use CANCEL to clear.");

      }

        • 1. Re: page number and template
          gkaiseril MVP & Adobe Community Professional

          The "P#" prefix is added when the template is spawned to a new page and the field names are renamed. The 'P#' prefix does not change when pages are deleted.

           

          It is difficult to tell what you are trying to do without a sample form and commented code.

           

          Have you opened the JavaScript console and checked for any errors?

           

          If you are going to put JS in template fields, you need to allow for the fact that they may fire within the template, so you need to add script to make sure the scripts that expect a created page from the template do not run if they are not on template spawned page.

           

          If your template is a copy of a form page that exist before any pages are spawned from the template that all the form fields on that page have their names adjusted to comply with the template naming.

          • 2. Re: page number and template
            MadMich Level 1

            Thanks for the reply

             

            I have added a link to a file which highlight my problem. It is a page extracted from a spawned document.

            The fields are using a document level script so they do not fire until the page is spawned.

             

            The second set of fields indicate what i am after from the first set but with page number, template and prefix 'X'.

             

             

            https://acrobat.com/?d=TjJ1RIBKSF6sW0qsqziKqw