Deleting Spawned Pages and final page buttons issue
Hope someone can help me out. I have a 3 page form (pages 2 and 3 are hidden as template pages).
On page 1 there are two Yes/No radio buttons - Q1 will spawn p2 if yes is selected and Q2 will spawn 3 if yes is selected. The problem I have not been able to solve is deleting the spawned pages when No is selected.
They can be clicked in any order so Q2 could be answered before Q1, I've set the spawn code so that pages appear in the correct order, no matter which Q is answered first. Both pages only spawn once so the code for them is set as follows (1 changed to 2 for second spawn page):
this.spawnPagesFromTemplate({
c.template: "Add 1",
nPage: 1,
bOverlay:false,
bRename:false,
)}
There is a hidden field called Spawn 1 and Spawn 2 on the two spawned pages so I thought I could use the code I found elsewhere in the forum to delete the spawned pages, but it's not working. I suspect the issue lies with my initial spawn code.
var f = this.getField("Spawn 1").page;
this.deletePages(f);
The second part of my problem is I have a submit button and caveat copy that should appear on the last page of the document (which could be any one of the 3 pages depending on Q1/2 answers). I initially tried to control this via the Q1 and Q2 Yes/No buttons but it only works if the answers are not changed. I thought about setting the visibility as conditional on page count but can't figure out where I would put any code for that - could I add the code to the Q1 and 2 yes/no buttons or would that clash with spawn commands?
Also I'm a bit unsure how to build/combine the code for all 3 pages, I made a start but know this isn't right and doesn't hide the other page footers:
if(this.numPages==1)
{
this.getField("P1 Footer").display = display.visible; this.getField("P1 Submit").display=display.visible}
else
if(this.numPages==2)
{this.getField("P2 Footer").display=display.visible; this.getField("P2 Submit").display=display.visible}
If anyone can point me in the right direction it would be much appreciated!
