I'm currently creating a form in which following pages can be spawned by templates.
For this I need consecutive numbers on the newly created pages which are aligned with the last number of the previous page.
I also have a plan how I want to do this. But I need the prefix of the previous page. How to determine the prefix of the current page I have found out. But how do I determine the prefix of the previous page?
var prefix = "";
var re = /(.+\.)(.+)/g;
var res = re.exec(event.target.name);
if (res != null)
prefix = res;
Thanks in advance for helping.
First, the prefix is always the number of the page where the template is spawned. So if it's spawned on page 25, the prefix is "P25".
So, there are several options for determining the prefix of the previous page.
1) If pages are created consecutively, then the previous prefix is just the previous page number.
2) You're script is creating the pages, so use a hidden field to track the numbers
3) Search all the field names to find all instances of the template, then workout which one is previous to the one on the current page.