You'll need to use fields for that.
They can have the following calculation script:
event.value = "Page " + (event.target.page+1) + " of " + this.numPages;
And after spawning the pages call the calculateNow method to update them.
That's worked quite nicely. It actually works now and also looks identical to the header after I made the field read only so that's good.
Just wondering what the point of the calculateNow method was as it currently works without using this bit of code.
I was not sure if the spawning command will cause the calculation events to
trigger, so I thought it's better to force it, to make sure they present
the correct value.
If you see it's not needed you can remove it, of course.
On 22 February 2018 at 00:52, sebastianb99835257 <firstname.lastname@example.org>
I have another related question to spawn pages.
When spawning pages all of my field names now have "P4.Template." in front of them.
var Zoomz = getField("Zoom_In_3");
Is there a way to for example set n = to the total number of pages minus 1. Then change my bit of code to be something like:
var Zoomz = getField("P"n".Template.Zoom_In_3");
No. The name of the spawned fields is determined by the template name, the page number and the original field name.
So it's predictable, but it's not changeable. You will need to modify your code to work with it.
I understand the way in which the template pages and fields are generated and that it's not changeable. I was basically asking if there is a way to set a dynamic variable (in this case what the page number is) and then reference it within the getField(...).
For example this is the hard coded field name:
var Zoomz = getField("P4.Template.Zoom_In_3");
I want to set the number in the P4 to be a variable and then reference the field that way. I'm just not sure how to use variables inside field names..
Something like this but I'm not sure of proper syntax or if this is even possible:
var Count = this.numPages;
var Zoomz = getField("P"Count".Template.Zoom_In_3");
Ah, sure, that's possible like this:
The plus-operator can be used to concatenate strings, including the values of variables, one to each other.