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

111

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
community guidelines

correct answers 1 Correct Answer

Most Valuable Participant , 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;}

Likes

Translate

Translate
Most Valuable Participant ,
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;

}

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

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
community guidelines
Most Valuable Participant ,
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.

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
community guidelines