Copy link to clipboard
Copied
Hello!
Need help. I have created a fillable PDF with 2 pages.
What I want is to have a Reset button for each page that only clears PDF fields on that page with a confirmation if they wish to continue before the actual clearing of the PDF fields.
Example:
Let us assume that on Page 1, I have the following PDF fields:
F01001
F02002
F02003
F03005
And on Page 2, I have the following PDF fields:
G03004
G03007
G06009
G07001
The Reset button on Page 1 should clear only those PDF fields on Page 1. The same with the Reset button on Page 2.
I wish that before actually clearing these PDF fields (either on Page 1 or Page 2), it would first ask the question, āDo you wish to continue (Y/N)?ā Only if the answer is Y will the clearing of PDF fields on that page will proceed.
Thank you in advance.
Sorry, I thought you wanted to clear fields on specific pages.
Use this in a button:
var resetTheseFields = ["F01002","F01005"];
var alert = app.alert("Are you sure you wish to delete fields on this page?",0,2);
if(alert == 4)
this.resetForm(resetTheseFields);
Copy link to clipboard
Copied
Use this as 'Document level script':
function resetFieldsOnPage(doc, p){
var fields = [];
for (var i=0; i<doc.numFields; i++) {
var f = doc.getField(doc.getNthFieldName(i));
if(f==null) continue;
if(fields.indexOf(f.name)==-1 && ((typeof f.page=="number" && f.page==p) || (typeof f.page=="object" && f.page.indexOf(p)!=-1)))
fields.push(f.name);}
return fields;}
Then use this in a 'reset' button as 'Mouse UP' event:
var alert = app.alert("Are you sure you wish to delete fields on this page?",0,2);
if(alert == 4){
var cFields = resetFieldsOnPage(this, 0);
this.resetForm(cFields);}
(this, 0) will reset fields on first page since first page is numbered 0, on second page change 0 to 1, on 3rd change to 2...etc.
Copy link to clipboard
Copied
Hi Nesa,
Thank you for replying to my concern.
Two questions:
1) Where can I define the Document level script?
2) What if I only want selected PDF fields on a certain page to be cleared and not all the PDF fields?
In the samples I have provided, I only want to clear F02002 and F02005. How can can I do this?
Thanks again.
Copy link to clipboard
Copied
Sorry, I thought you wanted to clear fields on specific pages.
Use this in a button:
var resetTheseFields = ["F01002","F01005"];
var alert = app.alert("Are you sure you wish to delete fields on this page?",0,2);
if(alert == 4)
this.resetForm(resetTheseFields);
Copy link to clipboard
Copied
Thank you, Nesa. Appreciate the help.
Copy link to clipboard
Copied
2.
Use this script:
var alert = app.alert("Are you sure you wish to delete fields on this page?",0,2);
if(alert == 4){
this.resetForm("F02002");
this.resetForm("F02005");
}
Copy link to clipboard
Copied
Thank you, JR for the help.
Copy link to clipboard
Copied
1.