Copy link to clipboard
Copied
I have 3 checkboxes named (NYC, NY and NJ) that spawn a template (all 3 are different templates) when checked and hides it when unchecked, but I need it to show a specific page not at the end, what am I missing? (im not a coder)
if(event.target.value!="Off")
{this.getTemplate("NYC" ).hidden=false;}
else
{this.getTemplate("NYC" ).hidden=true;}
The code I provided needs to be put into the original code that uses the check state to determine whether the template is spawned or deleted.
if(event.target.value!="Off")
{this.getTemplate("NYC" ).spawn(nTargetPageNumber, false, false);}
else
{this.deletePages(nTargetPageNumber);}
The trick for removing the page is to determine the actual page number. This is simple if nothing has changed since the template was spawned, but if other templates were spawned, then you'll need some way to find t
...Copy link to clipboard
Copied
You can spawn template pages where you want.
Copy link to clipboard
Copied
I can move it yes manually, but when i click on the checkbox it re spawns at the end of the form
Copy link to clipboard
Copied
The code you've shown does not "spawn" the page template. It hides and shows the actual template, which will always be placed at the end of the document. This will not work in the free Reader. To make the page appear at the desired location it has to be "spawned".
this.getTemplate("NYC" ).spawn(nTargetPageNumber, false, false);
Copy link to clipboard
Copied
Thank for you this very helpful. Now if I uncheck the box it "spawns" again is that supposed to be?
Copy link to clipboard
Copied
The code I provided needs to be put into the original code that uses the check state to determine whether the template is spawned or deleted.
if(event.target.value!="Off")
{this.getTemplate("NYC" ).spawn(nTargetPageNumber, false, false);}
else
{this.deletePages(nTargetPageNumber);}
The trick for removing the page is to determine the actual page number. This is simple if nothing has changed since the template was spawned, but if other templates were spawned, then you'll need some way to find the page. The best technique is to have a field with a unique name on the page.
Copy link to clipboard
Copied
Thank you very much Thom, it worked perfectly.
Copy link to clipboard
Copied
The code I provided needs to be put into the original code that uses the check state to determine whether the template is spawned or deleted.
if(event.target.value!="Off")
{this.getTemplate("NYC" ).spawn(nTargetPageNumber, false, false);}
else
{this.deletePages(nTargetPageNumber);}
The trick for removing the page is to determine the actual page number. This is simple if nothing has changed since the template was spawned, but if other templates were spawned, then you'll need some way to find the page. The best technique is to have a field with a unique name on the page.
By @Thom Parker
Hi Thom would you have an example or link to your Dot.Com (Subscribed) as an example
Copy link to clipboard
Copied
No I don't. But there are a few considerations.
1. If the fields are renamed, then the code needs to loop over all fields to find the unique one on the page.
2. If the template is spanwned more than once, then you'll need to have a way of determining the one you want. For example, if it's the last one, then you'll need to collect all the page numbers for the uique field and then select the last. This process is slightly different if the fields on the spawned page are not renamed. In that case the field.page property will contain an array of page numbers.
3. If the template page is hidden, which it should be, then code will find a field with an associated page number of -1. The code needs to specifically ignore this case.
So here's an example that fits with this thread. It assumes the template is spawned only once and the fields are not renamed.
var oFld = this.getField("UniqeName");
// if the page property of the field is a single number, then no spawning has taken place
if(typeof(oFld.page) == "object")
{// page property is an array, so must be spawned
var nPage = oFld.page[1];
this.deletePages(nPage);
}
Copy link to clipboard
Copied
Thank You Thom - I think it will give me something to work with
Keith