6 Replies Latest reply on Jan 17, 2014 2:24 PM by gkaiseril

    Hide/Unhide Various Field types w checkbox


      I am new to java programming.


      I am trying to hide multiple fields, checkboxes and radio button using one check box.

      This works for the fields but not the checkboxes or radio buttons.

      Your help is VERY much appreciated.


      This is what i have thus far:


      var nHide = event.target.isBoxChecked(0)?display.hidden:display.visible;


      this.getField("GLeffective").display = nHide;

      this.getField("GLcompany").display = nHide;

      this.getField("GLpolicynum").display = nHide;

      this.getField("GLpremium").display = nHide;

      this.getField("lossAmount1").display = nHide;

      this.getField("AUTOeffective").display = nHide;

      this.getField("AUTOcompany").display = nHide;

      this.getField("AUTOpolicynum").display = nHide;

      this.getField("AUTOpremium").display = nHide;

      this.getField("lossAmount2").display = nHide;

      this.getField("PROPeffective").display = nHide;

      this.getField("PROPcompany").display = nHide;

      this.getField("PROPpolicynum").display = nHide;

      this.getField("PROPpremium").display = nHide;

      this.getField("lossAmount3").display = nHide;

      this.getField("anylossesExplain").display = nHide;


      this.getField("PROPNoloss").display = nHide;

      this.getField("GLNoloss").display = nHide;

      this.getField("AUTONoloss").display = nHide;

      //Radio Buttons

      this.getField("anylosses").display = nHide;

      this.getField("PolicyDeclinedCancelled").display = nHide;

        • 1. Re: Hide/Unhide Various Field types w checkbox
          George_Johnson MVP & Adobe Community Professional

          I suspect there's an error, probably a misspelled field name in one of those lines. You can check by looking in the JavaScript console (Ctrl+J).

          • 2. Re: Hide/Unhide Various Field types w checkbox
            j@mε$ Level 1

            Thank you for your response.

            However, I have checked spelling all is correct.


            My checkboxes and radio buttons dont hide.

            and for some reason this appears


            This is my java debug:


            this.getField("anylossesExplain") is null


            TypeError: this.getField("anylossesExplain") is null


            • 3. Re: Hide/Unhide Various Field types w checkbox
              George_Johnson MVP & Adobe Community Professional

              Those errors mean that the "anylossesExplain" field does not exist. Note the case (capitalization) matters, so the field names have to match exactly. Also check for accidental leading/trailing spaces in the field names that you might not notice.

              • 4. Re: Hide/Unhide Various Field types w checkbox
                j@mε$ Level 1

                Thank you, George. Had a space in one and a capital in another.

                • 5. Re: Hide/Unhide Various Field types w checkbox
                  George_Johnson MVP & Adobe Community Professional

                  I find it helpful to enable the following user preferences regarding JavaScript (not java):


                  Edit > Preferences > JavaScript > Show console on errors and messages

                  Edit > Preferences > JavaScript > Enable interactive console


                  This way the console will automatically display whenever an error occurs and you'll have an immediate indication that something's wrong. The interactive part allows you to enter code, select it, and press Ctrl+Enter to execute it, which can be useful when debugging.

                  • 6. Re: Hide/Unhide Various Field types w checkbox
                    gkaiseril MVP & Adobe Community Professional

                    One approach is to use a function to get the field object and report an access issue. One could also add a function to adjust the display of the field and use the get field function.


                    function GetField(cName) {
                    // get field object;
                    var oField = this.getField(cName);
                    if(oField == null) app.aler("Error access field " + cName, 0, 0);
                    return oField;
                    } // end GetField function;

                    function DisplayField(cName, nDisplay) {
                    // hide field object;
                    // get field object;
                    var oField = GetField(cName);
                    oField.display = nDisplay;
                    } // end DisplayField

                    var nHide = event.target.isBoxChecked(0)?display.hidden:display.visible;
                    DisplayField("GLeffective", nHide)
                    DisplayField("GLcompany", nHide);
                    DisplayField("GLpolicynum", nHide)
                    DisplayField("GLpremium", nHide);
                    DisplayField("lossAmount1", nHide);
                    DisplayField("AUTOeffective", nHide);
                    DisplayField("AUTOcompany", nHide);
                    DisplayField("AUTOpremium", nHide);
                    DisplayField("lossAmount2", nHide);
                    DisplayField("PROPeffective", nHide);
                    DisplayField("PROPcompany", nHide);
                    DisplayField("PROPpolicynum", nHide);
                    DisplayField("PROPpremium", nHide);
                    DisplayField("lossAmount3",  nHide);
                    DisplayField("anylossesExplain", nHide);
                    DisplayField("PROPNoloss"), nHide);
                    DisplayField("GLNoloss"), nHide);
                    DisplayField("AUTONoloss", nHide);
                    //Radio Buttons
                    DisplayField("anylosses", nHide);
                    DisplayField("PolicyDeclinedCancelled", nHide);