Search code examples
javascriptacrobat

Adobe Acrobat toggle button - show/hide field


What I want is a button in Acrobat that would hide a field if it's visible and show it if it's hidden, alternatively.

I know there is a way to do one or the either on MouseUp, but I want to do both using the same button.

This where I got so far:

var Strikethrough = this.getField("text_strikethrough");
if(Strikethrough.display = display.hidden){Strikethrough.display = display.visible
} else {Strikethrough.display = display.hidden}

Unfortunately, it doesn't seem to be working.

Any help would be appreciated.


Solution

  • Try the following:

    var Strikethrough = this.getField("text_strikethrough");
    if(Strikethrough.display == display.hidden){Strikethrough.display = display.visible
    } else {Strikethrough.display = display.hidden}
    

    I used '==' instead of '=' in the "if condition".