Expand my Community achievements bar.

Incrementing the counter for every page

Avatar

Level 2

I need to print page numbers like below

1/2,2/2.

1/4,2/4,3/4,4/4.

1/3,2/3,3/3.

here I have values  2 ,4 and 3 and these values are getting from interface.

I need to increment the values from 1-2,1-4 and 1-3.

Please help me on this.

 

2 Replies

Avatar

Level 10

Hi Ashok1,

 

I'm not sure I understand when does the form know to go from 2/2 to 1/4 or 4/4 to 1/3.

 

Are there multiple master pages?  Maybe some images of your form hierarchy would help.

 

Regards

 

Bruce

Avatar

Employee

Well, here is a hack that might work for you (it did here)

In the initialize script of your root form place something like below which builds an array of page numbers

 

form1::initialize - (JavaScript, client)

var pagecnt = 1;
var secinput = new Array(2,4,3); // <-- fill this array from your data/interface

var pagelength = secinput.reduce(function(a, b) { return a + b; }, 0); // <-- get the overall number of pages or let it be calculated like this
pageout = new Array(pagelength+1); // make sure you do not put var in front which makes this array global

for (var i=0; i<secinput.length; i++) {
  for (var j=0; j<secinput[i]; j++) {
    pageout[pagecnt] = "" + (j+1) + "/" + secinput[i];
    pagecnt++;
  }
}

 

The pageout array contains ["1/2", "2/2", "1/4", "2/4", ....]

 

Then in the layout:ready event of a Text with floating field (like the Page # of # - I used Page #) that is placed on your master page have the following script:

 

form1.#pageSet[0].Page1.CurrentPage::ready:layout - (JavaScript, client)

var currpage = xfa.layout.page(this);
this.rawValue = pageout[currpage];

 

That produces in sequence on your pages:
Page 1/2
Page 2/2
Page 1/4
...

kprokopi_0-1594048326400.png

 

kprokopi_2-1594048417557.png

kprokopi_3-1594048494381.png