Copy link to clipboard
Copied
I have made a form that has checkboxes that populate / unhide hidden templates within the document. The templates appear at the end of the doucment but I would like them to be inserted right after the page with the checkbox. I have made the checkbox so that if the user has checked the wrong box in error that he/she can uncheck it and it will rehide itself. This is what I have so far. Are you able to help me out with the next step of having the page insert in the middle of the document and not the end? I'm feeling stumped.
function checkCheckbox(){
if (this.getField("1-3").isBoxChecked(0) == true) {
this.getTemplate("Authorities1-3").hidden=false;
} else {
this.getTemplate("Authorities1-3").hidden=true;
}
}
checkCheckbox();
Copy link to clipboard
Copied
When you unhide a Template page it will always appear as the last page of the file. You can then use the movePage command to move it elsewhere, if you wish.
Copy link to clipboard
Copied
PS. I hope you're aware this won't work in Reader... You can't unhide (or hide) Templates there.
Copy link to clipboard
Copied
No, I wasn't aware. Is there a way to make the inserting of a hiddent template work in reader for the unlisenced user?
Copy link to clipboard
Copied
You need to spawn pages from it, instead of unhiding it. One of the parameters of the spawn method allows you to specify where to spawn it to.
Copy link to clipboard
Copied
I have this, but I would like to make the page "go away" if the client unclicks the box. Is there a way to do this?
{
if(event.target.value == "Yes")
this.getTemplate("Beni1-10").spawn(event.target.page+1, true, false);this.getTemplate("Beni1-10").spawn(event.target.page+1, true, false);
this.pageNum = event.target.page+1;
}
Copy link to clipboard
Copied
Yes, you can use the deletePages command to remove the page, and if it's a spawned page it will also work in Reader (but not on other pages).
Copy link to clipboard
Copied
You can use this:
if(event.target.value == "Yes"){
this.getTemplate("Beni1-10").spawn(event.target.page+1, true, false);
this.pageNum = event.target.page+1;}
else
this.deletePages(event.target.page+1);
Copy link to clipboard
Copied
Thank you SOOOO much!
Is there a way to make it delete two spawned pages instead of just the one? Would the coding be,
this.deletePages(event.target.page+1);this.deletePages(event.target.page+2);
Copy link to clipboard
Copied
Use like this:
this.deletePages(event.target.page+1,event.target.page+2)
Copy link to clipboard
Copied
By the way...I so appreciate your help! I have been stuck on this for a bit.
Copy link to clipboard
Copied
OH MY GOODNESS! Thank you so much! It worked!
Copy link to clipboard
Copied
If I have inserted 4 templates, can I use this coding for deleting the 4 pages?
this.deletePages(event.target.page+1,event.target.page+2,event.target.page+3,event.target.page+4);
Copy link to clipboard
Copied
I've tried it and it only deletes two of the four pages.
Copy link to clipboard
Copied
It is a range, so use like this (event.target.page+1,event.target.page+4)
it will delete pages between that range.
Copy link to clipboard
Copied
Thank you so much!