Copy link to clipboard
Copied
Hi,
Am wondering if there is a script that would allow for a single page of field entries a user has made, to be cleared in entirety, likely using the function;
this.resetForm()
Ideally looking to achieve this with script that doesn't require naming each field individually (lots of fields!) like the example shown below, but perhaps just allows the reset of the page itself?.
this.resetForm(["Field1", "Field2", "Field5"]);
The standard reset form function in DC Pro is somewhat annoying in as much as if you then add more fields later on after setting which specific fields you have ticked earlier on in making the form, it seems to add those new fields as well, which is frustrating as quite often you might want to adapt and create more fields etc. later on.
1 Correct answer
You can find the code you need in this link:
https://answers.acrobatusers.com/Reset-one-page-of-multi-page-form-q51725.aspx
Copy link to clipboard
Copied
Do you want button on each page that will reset that page or you want button on first page that can reset any page?
Copy link to clipboard
Copied
Hi Asim123,
Button on each page that will reset that page.....;-)
Copy link to clipboard
Copied
You can find the code you need in this link:
https://answers.acrobatusers.com/Reset-one-page-of-multi-page-form-q51725.aspx
Copy link to clipboard
Copied
Hi NesaNurani,
Yes, did see that - but couldn't get it to work ;-(
Copy link to clipboard
Copied
Durr....my bad....i'd added a typo character when copying - works like a charm - thanks!
Copy link to clipboard
Copied
I want to do this also, but the link provided give me the 404 web error. Can you post a corrected link?
Copy link to clipboard
Copied
Hello - Looking for help with this also, but the link provided give me the 404 web error. Can you post a corrected link?
Copy link to clipboard
Copied
This code will reset all fields on the currently displayed page. It includes field that appear on both the target page and another page. This code will only operate in Acrobat DC, not on previous versions of Acrobat.
var nResetPage = this.pageNum;
var oFld, strFldName, aPgs, aFldNames=[];
for(var i=0;i<this.numFields;i++)
{
strFldName = this.getNthFieldName(i);
oFld = this.getField(strFldName);
aPgs = (typeof(oFld.page) == "number")?[oFld.page]:oFld.page;
if(aPgs.some(a=>a==nResetPage)) aFldNames.push(strFldName);
}
this.resetForm(aFldNames);
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Thanks so much Thom! This is a doc level script, correct?
Copy link to clipboard
Copied
I didn't write it for a specific location because I didn't know how it was to be used.
It's probably best to turn it into a document level function and then call it from a button.
function ResetFieldsOnPage(nResetPage){
var oFld, strFldName, aPgs, aFldNames=[];
for(var i=0;i<this.numFields;i++)
{
strFldName = this.getNthFieldName(i);
oFld = this.getField(strFldName);
aPgs = (typeof(oFld.page) == "number")?[oFld.page]:oFld.page;
if(aPgs.some(a=>a==nResetPage)) aFldNames.push(strFldName);
}
this.resetForm(aFldNames);
}
To use this on a MouseUp button script that resets the fields on the same page of the button, use this code
ResetFieldsOnPage(event.target.page);
The button name, must of course, not be repeated on any other page.
Use the Acrobat JavaScript Reference early and often

