Skip to main content
toddr14813053
Inspiring
September 23, 2020
Question

Dynamic Page Number - Calcuation

  • September 23, 2020
  • 1 reply
  • 1442 views

I have been trying to set up dynamic page numbering for a fillable form I have created. There are several fields on the form that cause pages to either spawn or delete, so I am wanting the script to auto update the page numbers and the total number of pages. I have been researching this for several days online and have found several different scripts and none of them seem to work properly. This is the one that has made the most headway.

 

event.value = "Page " + (event.target.page + 1) + " of " + (this.numPages);

 

The problem I am running into is that when I use the event.target.page I get weird answers like "-1,21 of 4" then "-1,31 of 4" on the next page, etc. Does anyone know why the form is calculating this way? The number is increasing, I guess, on each page and the total number of pages is correct, but that number formatting is wrong.

 

I have also tried this variation:

 

event.value = "Page " + (this.pageNum +1) + " of  " + (this.numPages);

 

That script just gives me "Page 1 of 4" on every page. The total number of pages is correct, but obviously the current page number is not.

 

Thoughts?

This topic has been closed for replies.

1 reply

try67
Braniac
September 23, 2020

This happens when you have multiple fields with the same name on different pages. In that case the page property returns an array of the page numbers, like [0, 1] if there's one field on page 1 and another on page 2, for example.

Each field must have a unique name if you want this script to work.

toddr14813053
Inspiring
September 24, 2020

Problem is I already had them with different field names. I even changed the fields names to something else and they still gave me the same answers. Any other ideas? Do you have any other coding that would work better in this situation?

try67
Braniac
September 24, 2020

I'll need to see the actual file to help you further with this issue.