how to hide all buttons

Explorer ,
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.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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;

}

TOPICS
Acrobat SDK and JavaScript, Windows

Views

98

Likes

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

how to hide all buttons

Explorer ,
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.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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;

}

TOPICS
Acrobat SDK and JavaScript, Windows

Views

99

Likes

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
Feb 28, 2018 0
Most Valuable Participant ,
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;

}

Likes

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
Reply
Loading...
Feb 28, 2018 0
Explorer ,
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.

Likes

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
Reply
Loading...
Feb 28, 2018 0
try67 LATEST
Most Valuable Participant ,
Feb 28, 2018

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Feb 28, 2018 0