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

Need help with javascript to show/hide all fields

Participant ,
Oct 14, 2017 Oct 14, 2017

I found this script in the forums and I was playing around with it and discovered it would hide all the fields but would not make them visible when I made the changes to visible. Here's the script:

var nButton = app.alert({

        cMsg: "Do you want to hide fields?",

        cTitle: "Make Read-Only?",

        nIcon: 2, nType: 2

    });

if (nButton == 4) {

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

        var fname = this.getNthFieldName(i);

        this.getField(fname).hidden = true; // makes all fields readonly

    }

}

this.getField("ButtonA").readonly = false;

this.getField("ButtonA").display = display.visible;

This script works to hide all fields but when I change "hidden" to "visible", and click the button, the fields remain hidden. I'd like to use something like this to hide/show the fields instead of using something like this to hide/show,

  this.getField("FieldA").display = display.hidden;

  this.getField("FieldA").display = display.visible;

(I have lots of fields to hide/show).

Can someone please show me how I can use the script above to hide and show my fields? I have two buttons, click button A to hide, click button B to make visible. I know this script above is to make the fields Read-Only but it also works to hide the fields so I thought it could also make the fields visible with a little modifying and expertise. Can someone let me know? Thank you guys.

TOPICS
Acrobat SDK and JavaScript , Windows
409
Translate
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 ,
Oct 14, 2017 Oct 14, 2017
LATEST

You should not be using the hidden property. It has been deprecated and replaced by the display property, which is what you're using in the rest of your code.

Translate
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