2 Replies Latest reply on Sep 22, 2014 12:32 AM by George_Johnson

    Grey out section if select radio button

    boredeasily

      Hi, this question is probably answered elsewhere, but I couldn't find. Am totally noob at Javascript or any scripting at all

      I have a form which is rather complicated, where the clients would only need to fill certain sections depending on their selection. Also the form in PDF may be printed out by some clients whom may not be comfortable filling it online.

       

      I have a few radio buttons, where if depending on the selection, a particular group of fields to become greyed out. . E.g. if selected option 1, the whole section A would be disabled (not hidden).

      radiobutton.png

       

      Can anyone help me with a script which can perform this function? Also, if the client decides to toggle to option 2, the Section A would be enabled back. Also when printed out, the section would still appear for Operations to be able to see that form is filled up as a whole.

       

       

      rgds

        • 1. Re: Grey out section if select radio button
          MichaelN Level 3

          First, make the 3 radio buttons have the same name, but with different Export values, such as Option1, Option2, Option3.

           

          Next, have all the fields in Section A named beginning with "SectionA.", such as SectionA.field1, SectionA.field2, SectionA.field3, etc.

           

          Then use this script as the mouse up action for the radio buttons:

           

          if (event.target.value!="Option1") {               //If Option1 radiobutton is off, unlock Section A
          this.getField("SectionA").readonly = false   
          }

          else this.getField("SectionA").readonly = true   //Otherwise, lock Section A

          • 2. Re: Grey out section if select radio button
            George_Johnson MVP & Adobe Community Professional

            It's also a good idea to reset any fields that you disable so that they don't then contain invalid data. So the script that Michael posted could be changed to:

             

            if (event.target.value != "Option1") {  // If Option1 radiobutton is off, unlock Section A

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

            } else {

                resetForm(["SectionA"]);  // Reset the SectionA fields

                this.getField("SectionA").readonly = true   //Otherwise, lock Section A

            }


            For this to work correctly, you have to set the SectionA fields to read-only before any of the radio buttons is selected.