1 Reply Latest reply on Aug 17, 2011 1:11 PM by George_Johnson

    Hiding Fields

    ktr927

      I'm needing a script that says to hide certain fields unless a certain checkbox is selected. I had something like this for a drop down box but I can't tweak it to get it to work for a checkbox. I know its probably something very simple but I'm still learning about all of this What i used for the dropdown box was:

       

           var t1 = this.getField("text1");

           var t2 = this.getField("text2");

           var t3 = this.getField("text3");

       

           t1.hidden = true;

           t2.hidden = true;

           t3.hidden = true;

       

           if (event.value == "Other")

                {  

       

                     event.willCommit = true;

       

           {

      t1.hidden = false;

      t2.hidden = false;

      t3.hidden = false;

                       }

                }

       

      So when users selected "Other" from the dropdown box the hidden field would show up. Now I just need it to be where when the user selects a certain checkbox the hidden fields will show up. Thanks in advance for your help!

       

       

        • 1. Re: Hiding Fields
          George_Johnson MVP & Adobe Community Professional

          Don't use the hidden field property since it has long been deprecated. Use the display property instead. To hide/show the fields when the check box is clicked, do something like the following in the Mouse Up event of the check box:

           

          // Get the value of this check box
          var val = event.target.value;
          
          // Show hide the fields based on the state of the check box
          if (val === "Off") {
              // Code to hide the fields goes here
          } else {
              // Code to show the fields goes here
          }