8 Replies Latest reply on Feb 26, 2015 5:38 AM by csb102155

    Template and Javascript

    csb102155 Level 1

      Hi, I have a form that has a template to add an additional page if the user needs more space to write in.

       

      I use this script:

       

      var oPage = this.pageNum;

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

      name

      a.spawn ({

      nPage: this.numPages+1,

      bRename:true,

      bOverlay:false

      });

       

      On the bottom of the form and each additional page the user needs to add on, is a coding block that must be on all pages. The coding block is the same information on all the other pages that is on the first page (lower section of each form.) Is there a way to write the script so that the field names in the coding block section only do not get renamed, but keep the same name as on the original document so that this information is the same on all pages?

       

      I use Adobe X Professional.

       

      Thanks

        • 1. Re: Template and Javascript
          George_Johnson MVP & Adobe Community Professional

          What you can do is set up another template page and make it hidden. The template page would be blank and include just the one field that you want. After you spwn the first template, spawn this second one on the newly create page, set bRename to false, and bOverlay to true.

          • 2. Re: Template and Javascript
            gkaiseril MVP & Adobe Community Professional

            You might try using 2 templates. One for adding a template that has the form fields to be renamed and one with the form fields not to be renamed. You spawn the new page for page with the form fields to be renamed and then overlay that page with template with form fields not be renamed.

            • 3. Re: Template and Javascript
              csb102155 Level 1

              Hi, thanks for getting back with me on this. My question now is this. I have a button that says "Additional Pages" that the user would click on to spawn a template page. Where would I put the script for the second template where the bRename would be false, and bOverly to true? Also, the script that I used above, is actually a little more detailed, it is:

               

              var oPage = this.pageNum;

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

              a.spawn ({

              nPage: this.numPages+1,

              bRename:true,

              bOverlay:false

              });

              this.pageNum++;

               

              I didn't know if that made a different or not.  Thanks

              Connie

              • 4. Re: Template and Javascript
                George_Johnson MVP & Adobe Community Professional

                You would place the code to spawn the second template right after the first. It doesn't look like you use the oPage variable, so I'm not sure what its purpose is.

                • 5. Re: Template and Javascript
                  csb102155 Level 1

                  Is this how the script on the button should be? Or am I missing something? It isn't working.

                   

                  var a = this.getTemplate("Additional");
                  a.spawn ({
                  nPage: this.pageNum+1,
                  bRename:true,
                  bOverlay:false
                  });
                  this.pageNum++;

                  var a = this.getTemplate("Additional1");
                  a.spawn ({
                  nPage: this.pageNum+1,
                  bRename:false,
                  bOverlay:true
                  });
                  this.pageNum++;

                  • 6. Re: Template and Javascript
                    George_Johnson MVP & Adobe Community Professional

                    You changed what you're using for the nPage value. For the second template, you should set the nPage value to match the page that was just added by spawning the first template.

                    • 7. Re: Template and Javascript
                      csb102155 Level 1

                      I'm sorry, I'm still not quite clear in what you're indicating here, can you clarify it more?  Thanks

                       

                      Here's the script that I am using.

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

                      a.spawn ({

                      nPage: this.numPages+1,

                      bRename:true,

                      bOverlay:false

                      });

                      this.pageNum++;

                       

                      var a = this.getTemplate("Additional1");

                      a.spawn ({

                      nPage: this.numPages+1,

                      bRename:false,

                      bOverlay:true

                      });

                      this.pageNum++;

                      • 8. Re: Template and Javascript
                        csb102155 Level 1

                        I've been working with this additional page and templates as suggested, but am still having problems with it. When I select the Additional Page button, using the code I have above, what happens is that it spawns 2 pages so I am not sure where the problem is. It does rename the field in the first spawn, and doesn't rename the field in the second spawn, so that part works okay. I'm having a hard time understanding, I think, how to handle this code - nPage: this.numPages+1. Any additional help with this would be greatly appreciated. I'd like to be able to offer my customers this resource if I could get it work right.

                         

                        Thanks

                        Connie