cancel
Showing results for 
Search instead for 
Did you mean: 

Number of Pages in Body Page

massimo_sforza
Participant
0 Kudos

Hi All,

i have a problem that i cannot solve because i cannot read the number of pages in Body Pages.

I try to explain better:

If i want to hide an element in the Master Page i can inserting this code in the element

if(xfa.layout.page(this) > 1) { this.presence = "hidden"; }

and it works!

but if i do the same with an element in Body Page it doesn't work... why?!?

Thanks a lot

KR

Massimo

Accepted Solutions (0)

Answers (1)

Answers (1)

pavan_prabhu
Active Participant
0 Kudos

Hello Massimo,

     If you want to hide the element which is in the body page, please check whether the code you have written on that element is in the Initialize event or not. It will not work if you have written it in Layout Ready event . It works in Initialize event.

massimo_sforza
Participant
0 Kudos

Hi Pavan,

same type of element, same javascript code in initialize

if(xfa.layout.page(this) > 1){  this.presence = "hidden"; }

but one element is in Master Page and the other in Body Page.

element in Master page is hidden and element in Body Page not.

i tried also using

if(xfa.host.currentPage > 0){  this.presence = "hidden"; }

in the element on Body Page but still doesn't work

Thanks for your help

KR

Massimo

pavan_prabhu
Active Participant
0 Kudos

Hello Massimo,


     You mean to say you have 2 elements in the Adobe layout design. One in the master page and the other in the body page right?

Can you tell me based on what condition you need to hide this element which is in the body page??

massimo_sforza
Participant
0 Kudos

I need it because i should put at the end of everything an element (subform ot table) at the beginning of the next page.

If this element is in a odd page it must be hidden, if the page is even it must to exist. This because i need always a number of even pages.

Acutually i have posted also another question for this but actually now i want also to konw why xfa.layout.page(this) it is recognized in Master Page and not in Body Page and if there is another script to do it.

Unfortunately i'm not good with javascript... so i can ask you if you know some good link to learn something about it in Adobe Forms.

Thanks a lot Pavan

KR

Massimo

pavan_prabhu
Active Participant
0 Kudos

Hello Massimo,

Your code will always work for master page no matter what. But it will not work the same for the body page because the document is not yet ready. You need to capture the element when the layout is ready to use.

Lets assume the name of the element you want to hide in the body page is "ELEMENT1".

Then write the below Javascript code on ELEMENT1 in Ready Layout event. Because the even and odd paging can be captured only after the layout is ready.

var currpage = xfa.layout.page(this);

var fields = 0;

fields = xfa.layout.pageContent(currpage-1, "field", 0);

------->Please Note that the value is 0 based. So I have taken current page - 1. Means the page number starts from 0,1,2 and so on.

In Javascript, use the Modulo operator to check whether it is even or odd page. Here the case will be reverse. That is 0,2,4,6... will be odd pages and 1,3,5,7.... will be even pages since the index starts from 0.

var mod = currpage%2;-------------------->First calculate the modulo result.

Now you need to hide it only if the element is in odd page. Normally for odd, the modulo result will be 1. But in this case the result for odd will be always 0 and for even it will be 1. So check if it is a zero, i.e the page is odd and only then hide that element.

if ( mod == 0 ) ---> check whether the page is odd

{

  for ( i=0; i<= fields.length-1; i++ ) ----> traverse all fields one by one

       {

            if ( fields.item(i).name == "ELEMENT1" ) ---> check if you found this field

            {

                 this.presence = "hidden"; ----> Hide this field

            }

       }

}


massimo_sforza
Participant
0 Kudos

Hi Pavan,

still i didn't try your suggestion but it looks very useful.

as soon as i can try it, i'll let you know...

Thanks a lot

BR

Massi