Copy link to clipboard
Copied
Hi everyone,
I've searched the forums here and found a link to solve my problem but the link keeps giving me the dreaded "404" error. Here is the link: https://answers.acrobatusers.com/Reset-one-page-of-multi-page-form-q51725.aspx
What I want to do is make a Reset Page button on each of my 6-page form so only that one page will reset. I already have a Reset Form button and it works fine. I know I can use the this.resetForm(["Field1", "Field2", "Field5"]); format, but I have about 7 dozen fields on each page and that is quite tedious to enter all those fields per page. I'm hoping there's an easier way. Can someone who can access that link with the answer above, please post the answer so I can use it?
It's a real tragedy that the AcrobatAnswers forum is no longer accessible. It contained a lot of excellent answers and resources...
Here's a function I wrote that will return all the names of the fields on a specific page:
function getFieldsOnPage(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
...
Copy link to clipboard
Copied
It's a real tragedy that the AcrobatAnswers forum is no longer accessible. It contained a lot of excellent answers and resources...
Here's a function I wrote that will return all the names of the fields on a specific page:
function getFieldsOnPage(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;
}
You can use it like this, for example:
var page1Fields = getFieldsOnPage(this, 0);
this.resetForm(page1Fields);
Copy link to clipboard
Copied
function getFieldsOnPage(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;
}
You can use it like this, for example:
var page1Fields = getFieldsOnPage(this, 0);
this.resetForm(page1Fields);
By @try67
Thanks, but I have a question. I entered the two lines in your bottom example and that seems to work well. What is all the stuff in the first example? I tried that one first and nothing happens.
Copy link to clipboard
Copied
It can't work if you only entered the last two lines... You have to use the first part, which is the function definition of the getFieldsOnPage method. You can place it as a doc-level script and then call it from anywhere in the file.