Highlighted

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

Avatar

Guest

16-12-2008

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

Replies

Highlighted

pguerett

16-12-2008

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.
Highlighted

Avatar

Guest

16-12-2008

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.
Highlighted

pguerett

16-12-2008

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";

}