Copy link to clipboard
Copied
Hello. I am trying to build a button that will generate a new page in the middle of the document and also the new pages will have different filed names so that different inputs can be captured. I found a script here for that and tried using it for my form/ While it has solved the problem of same field's input not repeating in the new generated pages, my problem that the new pages are generated in the last page remains. See I have a 8 pages Form. The action button "Add Page" is located in the third page and I need the new pages to be generated just after this page (not in the last) with different field names. I can not seem to figure out what I need to change in the script to do this. If I change the 'this.numpage' to 3, new pages are generated after page 3 but they have the same filed names. I am using the below script for now where pages are generating at the last with differnet field names. Please suggest what I need to change.
// define variable for the named MyTemplate;
var SpawnPage = this.getTemplate({cName: "Page 3(1)"});
// spawn the new page and rename the field names;
SpawnPage.spawn({nPage: this.numPages, bRename: true, bOverlay: false});
// set focus to new page Name field;
this.getField("P" + (this.numPages - 1) + ".MyTemplate.Name").setFocus();
Copy link to clipboard
Copied
You have to keep a counter of how many pages you spawned and always spawn the new page after the last one.
This can be done with a variable or even based on the total number of pages in the file before spawning.
PS. You posted in the Reader forum but you're obviously using Acrobat, as this can't be done in Reader, so I'm moving your question to that forum...