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

JavaScript Exception

Guest
Aug 25, 2016 Aug 25, 2016

Hi there,

I wish to know the extension of the Javasript to make an entire PDF read only Except one button. I currently have the coding that will make the whole document 'read only' however I Wish to have an exception for the 'submit' button.

Please let me know what the code extension to the below is:

for (var i = 0; i < this.numFields; i++) {

    var fname = this.getNthFieldName(i);

    this.getField(fname).readonly = true; // makes all fields readonly

     }

TOPICS
Acrobat SDK and JavaScript , Windows
280
Translate
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
LEGEND ,
Aug 26, 2016 Aug 26, 2016

Try this:

for (var i = 0; i < this.numFields; i++) {

    var fname = this.getNthFieldName(i);

    if (fname !== "NameOfButtonToExclude") {

        this.getField(fname).readonly = true; // makes all fields readonly

    }

}

but replace "NameOfButtonToExclude" with the actual name of the button you want to exclude.

Translate
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 ,
Aug 26, 2016 Aug 26, 2016
LATEST

Hi.

You don't need an exception: just lock all fields, then unlock the button.

for (var i = 0; i < this.numFields; i++) {

    var fname = this.getNthFieldName(i);

    this.getField(fname).readonly = true; // makes all fields readonly

    }

this.getField(MYBUTTON).readonly = false;


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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