Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

How to you reference the current page number and total pages in a script?

Not applicable
I'm trying write a small script to make field invisible when the current page equals the total number of pages, but with no luck.



Can anyone advise how to do this?



I've tried various ways to reference my fields, this being the most basic:



if(pageNumber == totalPages) {

continuedBase.presence = "invisible";

}



// pageNumber has a run time property as "Current Page Number"

// totalPages has a run time property as "Number of Pages"

// continuedBase is a text field within the same subform as pageNumber and totalPages



Thanks for any help offered.



Russell
4 Replies
pguerett
Level 10
Level 10
Do an app.alert("The page number is: + pageNumber) before the if statement and ensure that you are getting the correct values. Also check the totalPages.
Not applicable
Thanks Paul,



I'm very new to this (I'm still using the demo version!!), I not sure how to implement your suggestion, could you explain?



Thank you.
pguerett
Level 10
Level 10
If you are asking how to get the current page and total pages you acn use these commands:



current page ----- xfa.layout.page(this)

total pages ------ xfa.layout.pageCount()



so your code woudl look like this:



app.alert("The curent page is: " + xfa.layout.page(this));

app.aler("The total number of pages is: " + xfa.layout.pageCount());



if(xfa.layout.page(this) == xfa.layout.pageCount()) {

continuedBase.presence = "invisible";

}
Not applicable
Works a treat, you are a star! Thank you so much!!!!



Russell