Copy link to clipboard
Copied
Hi all
I am working on a form in Acrobat. It is a training form with Competent/Not Yet Competent (C/NYC). The form will auto select C/NYC depending on the checkbox selections. If they are Not Yet Competent then two pages will spawn for the reassessment component. These forms are hidden at the start.
For Competent the script will delete the last two pages. As these pages are hidden at the start and iff the person is assessed as Competent at the start the calculate script runs but stops at the deletepages part of the script and won't proceed.
Is there a way for this delete script to take into account the pages may or may not be there. The script I'm using is as follows:
if (this.getField("Check Box1").value == "Yes"
&& this.getField("Check Box2").value == "Yes"
&& this.getField("Check Box3").value == "Yes"
&& this.getField("Check Box4").value == "Yes"
&& this.getField("Check Box5").value == "Yes"
&& this.getField("Check Box6").value == "Yes"
&& this.getField("Check Box7").value == "Yes" ) {
this.getField("ResultCB").value = "Yes";
this.deletePages({nStart: 5, nEnd: 6 });
}
Any assistance is appreciated.
Gary
Yes, add it before:
this.deletePages({nStart: 5, nEnd: 6 });
Like this:
if (this.numPages>=7) this.deletePages({nStart: 5, nEnd: 6 });
Copy link to clipboard
Copied
You can check the number of pages in the file before deleting them. If the number is less than 7, don't proceed.
Copy link to clipboard
Copied
try
How would I do that? I am not well versed in Javascript.
Gary
Copy link to clipboard
Copied
Add this to the if condition:
if (this.numPages>=7 && ...
Copy link to clipboard
Copied
try
Where would I place that in the script provided? If I place it at the start then line 8 of the script won't occur if >=7. Is that correct?
Gary
Copy link to clipboard
Copied
Yes, add it before:
this.deletePages({nStart: 5, nEnd: 6 });
Like this:
if (this.numPages>=7) this.deletePages({nStart: 5, nEnd: 6 });
Copy link to clipboard
Copied
Worked a treat. Thank you.