Skip to main content
sebastianb99835257
Inspiring
February 28, 2018
Answered

how to hide all buttons

  • February 28, 2018
  • 1 reply
  • 825 views

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.

This topic has been closed for replies.
Correct answer try67

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;

}

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
February 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;

}

sebastianb99835257
Inspiring
February 28, 2018

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.

try67
Community Expert
Community Expert
February 28, 2018

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