Skip to main content
first.officer
Inspiring
Oct 10, 2020 4:51 PM UTC
Answered

JavaScript to reset fields on specific page within document

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.

This topic is closed to new replies. Start a new post to keep the conversation going.
Nesa Nurani
Nesa NuraniCorrect answer
Community Expert
Oct 10, 2020 6:17 PM UTC

10 replies

goldilocks22
Participating Frequently
Oct 20, 2022 3:24 PM UTC

Hello - Looking for help with this also, but the link provided give me the 404 web error. Can you post a corrected link?

Translate
Thom Parker
Community Expert
Community Expert
Oct 20, 2022 5:49 PM UTC

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);

 

 

 

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
goldilocks22
Participating Frequently
Oct 20, 2022 6:29 PM UTC

Thanks so much Thom!  This is a doc level script, correct?

Translate
Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
Oct 10, 2020 6:17 PM UTC

You can find the code you need in this link:

https://answers.acrobatusers.com/Reset-one-page-of-multi-page-form-q51725.aspx 

 

Translate
first.officer
Inspiring
Oct 10, 2020 6:37 PM UTC

Hi NesaNurani,

 

Yes, did see that - but couldn't get it to work ;-(

Translate
first.officer
Inspiring
Oct 10, 2020 6:50 PM UTC

Durr....my bad....i'd added a typo character when copying - works like a charm - thanks!

Translate
Inspiring
Oct 10, 2020 5:49 PM UTC

Do you want button on each page that will reset that page or you want button on first page that can reset any page?

Translate
first.officer
Inspiring
Oct 10, 2020 5:54 PM UTC

Hi Asim123,

 

Button on each page that will reset that page.....;-)

Translate