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

how to hide all buttons

Explorer ,
Feb 28, 2018 Feb 28, 2018

Copy link to clipboard

Copied

Hi All,

With a button click I am making my form read only and attaching it to an email.

The only thing is I want to be able to hide all of the JavaScript buttons on the page.

I am aware of the this way to hide buttons:

this.getField("Email_Button").display = 1;

The problem is I am using spawn pages and thus its hard to use the above bit of code to hide all potential buttons.

Is there a bit of code that can select all buttons or cycle through all buttons on my pdf and hide them?

Cheers,
Seb.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

417

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 , Feb 28, 2018 Feb 28, 2018

Yes. You can use this code to do it:

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

    var f = this.getField(this.getNthFieldName(i));

    if (f==null) continue;

    if (f.type=="button") f.display = display.hidden;

}

Votes

Translate

Translate
Community Expert ,
Feb 28, 2018 Feb 28, 2018

Copy link to clipboard

Copied

Yes. You can use this code to do it:

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

    var f = this.getField(this.getNthFieldName(i));

    if (f==null) continue;

    if (f.type=="button") f.display = display.hidden;

}

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 ,
Feb 28, 2018 Feb 28, 2018

Copy link to clipboard

Copied

Thanks try that works great.

One other question is there a way to test button/field visibility in an if statement.. something like this:

if( getField("Button_Name").display = 1) {

     //Do Something

} else {

     //Do Something Else

}

Cheers,

Seb.

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 ,
Feb 28, 2018 Feb 28, 2018

Copy link to clipboard

Copied

LATEST

Yes, but the comparison operation is "==", not "=". That's the value assignment operator... It's a common mistake.

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