• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

JavaScript to reset fields on specific page within document

Engaged ,
Oct 10, 2020 Oct 10, 2020

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.

TOPICS
Acrobat SDK and JavaScript

Views

1.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 10, 2020 Oct 10, 2020

Votes

Translate

Translate
Enthusiast ,
Oct 10, 2020 Oct 10, 2020

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 10, 2020 Oct 10, 2020

Copy link to clipboard

Copied

Hi Asim123,

 

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 10, 2020 Oct 10, 2020

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 10, 2020 Oct 10, 2020

Copy link to clipboard

Copied

Hi NesaNurani,

 

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 10, 2020 Oct 10, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 07, 2021 Apr 07, 2021

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 20, 2022 Oct 20, 2022

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 20, 2022 Oct 20, 2022

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

 

 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 20, 2022 Oct 20, 2022

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 20, 2022 Oct 20, 2022

Copy link to clipboard

Copied

LATEST

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.

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines