4 Replies Latest reply on Jun 4, 2012 2:06 PM by Tuckitaway

    Single Checkbox Disables a Seperate Group of Checkboxes

    Tuckitaway

      checkbox problem.jpg

      on this form, i want the "reactions of people" checkbox to disable the ability to select the other fields and vise versa. I tried to do it with the following script,

       

      function disable_check_boxes_DDC()

      {

      var cAgree = this.getField(ReactionsOfPeopleAllSafe).value;

      if( cAgree == "Yes" ) {

      // make the following check boxes read only

      var oField = this.getField("AdjustPPE");

      oField.readonly = true;

      oField = this.getField("ChangingPositions");

      oField.readonly = true;

      oField = this.getField("RearrangeJob");

      oField.readonly = true;

      oField = this.getField("StoppingJob");

      oField.readonly = true;

      oField = this.getField("InitiatingSafetyStandards");

      oField.readonly = true;

      oField = this.getField("OtherReactions1");

      oField.readonly = true;

      oField = this.getField("OtherReactions2");

      oField.readonly = true;

      } else {

      // make radio buttons RW

      var oField = this.getField("AdjustPPE");

      oField.readonly = false;

      oField = this.getField("ChangingPositions");

      oField.readonly = false;

      oField = this.getField("RearrangeJob");

      oField.readonly = false;

      oField = this.getField("StoppingJob");

      oField.readonly = false;

      oField = this.getField("InitiatingSafetyStandards");

      oField.readonly = false;

      oField = this.getField("OtherReactions1");

      oField.readonly = false;

      oField = this.getField("OtherReactions2");

      oField.readonly = false;

      } // end process Check Boxes

      }

      But can't quite seem to get it to work.

       

      Any advice would be great!

       

      I am using Adobe Acrobat X Pro

        • 1. Re: Single Checkbox Disables a Seperate Group of Checkboxes
          George_Johnson MVP & Adobe Community Professional

          You didn't say where you placed that code. In any case, you can make it much easier on yourself if you use a hierarchical naming convention so that the field names of the group share a common prefix (e.g., "group1.AdjustPPE", "group1.ChangingPositions"), etc.), the code could be simplified to just:

           

          // Mouse Up script for check box

           

          // Get the value of this check box

          var v1 = event.target.value;

           

          // Get a reference to all of the fields in the group

          var f = getField("group1");

           

          // Set the fields to readonly based on the state of this check box

          f.readonly = v1 !== "Off";

           

           

          In addition to making the fields read-only, you should consider resetting all of the group1 fields as well. If you need help with that, post again and include the fields names if you decided to rename them.

          1 person found this helpful
          • 2. Re: Single Checkbox Disables a Seperate Group of Checkboxes
            Tuckitaway Level 1

            Thanks George

             

            Great suggestion on getting the "all safe" field to clear the others! I'll do that for sure. As you can imagine, i am a Java Rookie trying to fumble my way through the creation of a few .pdf forms and learning as i go. I ran this script

             

            //Mouse Up Script for CheckBox
            {
            var v1 = event.target.ReactionsOfPeopleAllSafe.On;

            var f = getField("group1.AdjustPPE");
            var f = getField("group1.ChangingPositions");
            var f = getField("group1.RearrangingJob");
            var f = getField("group1.StoppingJob");
            var f = getField("group1.InitiatingSafetyStandard");
            var f = getField("group1.Other1");
            var f = getField("group1.Other2");

            f.readonly = v1 !== "Off";

             

            and it just turns-off the "group 1" fields whether the All Safe Box is checked or not.

            • 3. Re: Single Checkbox Disables a Seperate Group of Checkboxes
              George_Johnson MVP & Adobe Community Professional

              That line of code near the beginning should be:

               

              var v1 = event.target.value;

               

               

              Assuming you placed it in the Mouse Up event of the check box. Also, remove the left curly bracket that you have after the comment.

               

              Also, you don't need all of those other lines of code. If you changed the field names as suggested, the code I posted should work.

              • 4. Re: Single Checkbox Disables a Seperate Group of Checkboxes
                Tuckitaway Level 1

                Thanks a Million George!

                 

                Worked like a charm!

                 

                I'll try that field clearing line too you feel like sending it along