1 Reply Latest reply on Oct 14, 2017 2:15 PM by try67

    Need help with javascript to show/hide all fields

    pdfUser1 Level 1

      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.