5 Replies Latest reply: Apr 18, 2012 7:06 AM by Theresa1214 RSS

    Radio buttons with dropdowns?

    Theresa1214

      I'm creating a form for my company's HR department, and I need some radio buttons with dependent dropdowns.

       

      In other words, I'd like (for example) three radio buttons. No dropdowns appear until one of the buttons is selected, and then the appropriate dropdown appears. Is this possible? Or is there a better way to do this? I don't want the unselected dropdowns to be available.

       

      I have Pro 9 for Windows and Pro X for Mac. I know virtually nothing about scripting, but I know that it can be done.

       

      Thanks in advance for any help!

       

      Theresa

        • 1. Re: Radio buttons with dropdowns?
          try67 CommunityMVP

          You need to associate scripts with the radio-buttons that check their current value and show/hide the drop-downs based on it.

          Use the MouseUp-action. For example, if the radio-group is called "Radio1" and it has the values 1, 2, and 3 and you want to show "Combo1" if 1 is selected, "Combo2" if 2 is selected, etc., use this code as the MouseUp action:

           

          Radio1MouseUp()

           

          And then embed this code at the doc-level:

           

          function Radio1MouseUp() {

          var v = this.getField("Radio1").value;

          this.getField("Combo1").display = (v=="1") ? display.visible : display.hidden;

          this.getField("Combo2").display = (v=="2") ? display.visible : display.hidden;

          this.getField("Combo3").display = (v=="3") ? display.visible : display.hidden;

          }

          • 2. Re: Radio buttons with dropdowns?
            Theresa1214 Community Member

            Okay...that sure seems like it will work.

             

            My knowledge is more basic, though, so things aren't clicking just yet.

             

            Do I add this code to the group's action, or to individual radio button actions? Do I make the dropdowns visible or hidden? Do I put any code in the dropdown properties, or just in the radio button properties? And when you say "embed this code at the doc-level," what does that mean?

             

            Thank you for helping!

            • 3. Re: Radio buttons with dropdowns?
              try67 CommunityMVP

              Do I add this code to the group's action, or to individual radio button actions?

              To each individual radio-button.

               

               

              Do I make the dropdowns visible or hidden?

              Their visibility will be determined by the state of the radio-buttons. As default you can set them to be hidden, when no radio button is selected.

               

               

              Do I put any code in the dropdown properties, or just in the radio button properties?

              Just in the radio buttons.

               

               

              And when you say "embed this code at the doc-level," what does that mean?

              Go to Advanced - Document Processing - Document JavaScripts...

              Create a new script, remove the default text that appears in the window and paste the code I provided instead.

              • 4. Re: Radio buttons with dropdowns?
                Theresa1214 Community Member

                Brilliant!

                 

                Thank you so much. I suppose I should enroll for some scripting instruction.

                • 5. Re: Radio buttons with dropdowns?
                  Theresa1214 Community Member

                  One more question on this topic...

                   

                  The button/combo list works great until I clear the form. The button selections are cleared, but the last chosen dropdown stays visible.

                   

                  Is it possible to add something to the script to make the dropdown default to "hidden" when the form is cleared?

                   

                  Thanks again for your help!