5 Replies Latest reply on Feb 29, 2016 8:52 AM by MADink_Designs27

    Using value of check box to show/hide radio buttons?

    virgonightingale

      I'm creating a pdf form. I have a check box, and several radio buttons beneath. I have it set so the radio buttons are hidden until the check box above it is clicked. I also set the check box to reset the radio buttons on mouse-up. However, the radio buttons are still selectable. I want to make sure that if one of the radio options is selected, that the check box be checked off as well.

       

      Is there a bit of javascript I could add to the check box to hide the radio buttons if its value is not equal to yes (checked off)?

        • 1. Re: Using value of check box to show/hide radio buttons?
          gkaiseril MVP & Adobe Community Professional

          Can you post the JavaScript code that you are using?

           

          You should not be using the 'Show/Hide" option on the "Mouse Up" action as the check box could be checked or unchecked by this option and you appear to want one action if the check box is checked and a different action when it is not checked. So this would require that you need to check the value of the check box on the mouse up action.

          • 2. Re: Using value of check box to show/hide radio buttons?
            virgonightingale Level 1

            I have no javascript there as of yet.

             

             

            This is what my form has:

             

            O Yes, I want to reserve space in the ad journal.

                Please select the ad you'd like:

                O Full Page

                O Half Page, etc.

             

             

            I don't want the ad options to be available unless the box next to 'Yes' is checked. Right now, if someone changes their mind and unchecks the box, the ad option buttons reset, but they're still available to click on.

             

            That's why I'm looking for a way to use the value of the check box to determine whether the options are available. Like "if this checkbox value does not equal yes, these radio buttons are hidden". I know what I want the script to say, I just lack the syntax to make it work. I'm a graphic designer who specializes in print, coding is so not my forté.

            • 3. Re: Using value of check box to show/hide radio buttons?
              gkaiseril MVP & Adobe Community Professional

              You could use code similar to

               

              if(event.target.value =="Yes") {
              // selected - show radio buttons
              this.getField('Radio Button1').display = display.visible; // show radio button
              } else {
              // deselected show hide the radio buttons and reset the field
              this.getField('Radio Button1').display = display.hidden; // hide radio button
              this.resetForm(['Radio Button1']); // clear radio button
              }

              But yoy will need to change the field name for "Radio Button1" to match your field name fyouor the radio button group.

              • 4. Re: Using value of check box to show/hide radio buttons?
                virgonightingale Level 1

                That worked perfectly. I was even able to adapt it for similar use in a different part of the form. Thanks so much, it's greatly appreciated!

                • 5. Re: Using value of check box to show/hide radio buttons?
                  MADink_Designs27 Level 1

                  I have something I'm trying to do that's similar, but not exactly. I have two sets of four buttons that are identical except for the name of the button.

                   

                  I'd like the code to say if this checkbox is checked, the button display is equal to it's counterpart. The below almost works, but once I get to the fourth one, it doesn't appear...so only three of them work. I haven't started coding the else statement if pass isn't checked.

                   

                  Below is my entire code doing other things such as displaying specific buttons if specific combinations of checkboxes are selected. What we're looking at is the last else if at the bottom. I'm open to other ideas on code to get the results I want.

                   

                  The trick is to get it all to work together with the existing code that works.

                   

                  //SW1-T1
                  if(av.value == "Off" && mood.value == "Off" && lock.value == "Off" && aisle.value == "Off" && reading.value == "Off") {
                      sw1t5.display = display.hidden;
                      sw1t4.display = display.hidden;
                      sw1t3.display = display.hidden;
                      sw1t2.display = display.hidden;
                      sw1t1.display = display.visible;
                      contact.display = display.hidden;
                      sw2.display = display.hidden;
                  }
                  //SW1-T2
                  else if(av.value == "Off" && mood.value == "Yes" && lock.value == "Off" && aisle.value == "Off" && reading.value == "Off") {
                      sw1t5.display = display.hidden;
                      sw1t4.display = display.hidden;
                      sw1t3.display = display.hidden;
                      sw1t2.display = display.visible;
                      sw1t1.display = display.hidden;
                      contact.display = display.hidden;
                      sw2.display = display.hidden;
                  }
                  //SW1-T3
                  else if(av.value == "Yes" && mood.value == "Yes" && lock.value == "Off" && aisle.value == "Off" && reading.value == "Off") {
                      sw1t5.display = display.hidden;
                      sw1t4.display = display.hidden;
                      sw1t3.display = display.visible;
                      sw1t2.display = display.hidden;
                      sw1t1.display = display.hidden;
                      contact.display = display.hidden;
                      sw2.display = display.hidden;
                  }
                  //SW1-T4
                  else if(av.value == "Yes" && mood.value == "Yes" && lock.value == "Off" && aisle.value == "Yes" && reading.value == "Yes") {
                      sw1t5.display = display.hidden;
                      sw1t4.display = display.visible;
                      sw1t3.display = display.hidden;
                      sw1t2.display = display.hidden;
                      sw1t1.display = display.hidden;
                      contact.display = display.hidden;
                      sw2.display = display.hidden;
                  }
                  //SW1-T5
                  else if(av.value == "Yes" && mood.value == "Yes" && aisle.value == "Yes" && reading.value == "Yes" && lock.value == "Yes") {
                      sw1t5.display = display.visible;
                      sw1t4.display = display.hidden;
                      sw1t3.display = display.hidden;
                      sw1t2.display = display.hidden;
                      sw1t1.display = display.hidden;
                      sw2.display = display.visible;
                      contact.display = display.hidden;
                      contact2.display = display.hidden;
                      pass.value = "Yes";
                  }
                  //SW2-T1
                  else if(av.value == "Yes" && mood.value == "Yes" && aisle.value == "Yes" && reading.value == "Yes" && lock.value == "Yes" && panel.value == "Yes") {
                      sw1t5.display = display.visible;
                      sw1t4.display = display.hidden;
                      sw1t3.display = display.hidden;
                      sw1t2.display = display.hidden;
                      sw1t1.display = display.hidden;
                      sw2t1.display = display.visible;
                      sw2.display = display.visible;
                      contact.display = display.hidden;
                      contact2.display = display.hidden;
                      pass.value = "Yes";
                  }
                  //Show SW2 Buttons
                  else if(pass.value == "Yes") {
                      av_btn2.display = av_btn.display;
                      mood_btn2.display = mood_btn.display;
                      reading_btn2.display = reading_btn.display;
                      aisle_btn2.display = aisle_btn.display;
                  }
                  else {
                      sw1t5.display = display.hidden;
                      sw1t4.display = display.hidden;
                      sw1t3.display = display.hidden;
                      sw1t2.display = display.hidden;
                      sw1t1.display = display.hidden;
                      sw2t1.display = display.hidden;
                      contact.display = display.visible;
                      contact2.display = display.hidden;
                      sw2.display = display.hidden;
                      av_btn2.display = display.hidden;
                      mood_btn2.display = display.hidden;
                      reading_btn2.display = display.hidden;
                      aisle_btn2.display = display.hidden;
                      panel_btn2.display = display.hidden;
                  }