Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

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

Avatar

Former Community Member
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

Avatar

Former Community Member
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.

Avatar

Former Community Member
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.

Avatar

Former Community Member
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";

}

Avatar

Former Community Member
Works a treat, you are a star! Thank you so much!!!!



Russell