7 Replies Latest reply on Feb 26, 2018 1:54 PM by try67

    How to set If/Then Logic for Drop Downs ?

    SSCSteven Level 1

      I have a Drop Down (Drop Down 1) with 3 options - "Yes", "No", and "SELECT YES/NO"

      I am using this because I think it will be easier to manage that Radio Buttons or Check Box groups for Yes/No.

       

      1. How do I "reset" the Drop Down to have no selection - so I dont have to use a "SELECT YES/NO" type of field. How do I get that drop down to just be Blank by default, until the User selects something?

       

      2. Based on the output value of the Drop Down, I would then like a series of 10 more Drop Downs to be Required.

       

      If Drop Down 1 is Yes - then 1 Text Field is Required, and 10 additional Drop Downs are Required - and the from cannot be Submitted using a Mouse Click Submit action until all 10 required Drop Downs are populated.

       

      If Drop Down is No - then 1 Text Field is not required, and 10 additional Drop Downs are not required - and the form can be Submitted using Mouse Click Submit Action.

       

      Note: These are all Yes/No fields - so if there is an easier way to do this with Radio Buttons or Check Boxes - then please let me know - happy to use those as well - however I realize that Radio Boxes and Check Boxes might pose a problem if the user Selects One and then later changes their mind and wants to Select another.

       

      Ideally - this would be setup so that the Required Fields changes its Required setting - if the Drop Down changes.

       

      Thank you all !!! 

        • 1. Re: How to set If/Then Logic for Drop Downs ?
          try67 MVP & Adobe Community Professional

          1. You can't do that, unless you tick the option to allow custom user input (but then the users will be able to enter something beside Yes/No...). What you can do is create a default item which is a single space, for example, so it appears as if the field is empty when that item is selected.

          2. This can be done using a script. What are the names of these fields?

          • 2. Re: How to set If/Then Logic for Drop Downs ?
            George_Johnson MVP & Adobe Community Professional

            For #1, before setting up any items in the list, set up a custom Validate script for the dropdown that is simply:

             

            // Validate script for dropdown

            event.rc = false;

             

             

            Then add the list items to the dropdown using a script like the following, in the Mouse Up script of a temporary button, for example:

             

            // Array of list items for a dropdown

            var aWhiskyList = ["Lagavulin", "Ardbeg", "Laphroaig", "Caol Ila"];

             

            // Populate the dropdown with items in the above array

            getField("Whisky").setItems(aWhiskyList);

             

            Then remove the dropdown's Validate script.

             

            At this point, the dropdown value should be blank (zero length string), and it should also include the list items that you set.

             

            A problem with this approach is that it's difficult or impossible (depending on PDF viewer being used) to reset the form to this initial state where no item is selected. This setup is essentially the same as a radio button group with none of the buttons selected. An advantage to using radio buttons is they can easily be reset so that none is selected, but they will generally take up more real estate on a page.

            • 3. Re: How to set If/Then Logic for Drop Downs ?
              SSCSteven Level 1

              For #2 - The names of the fields are as Follows:

              Drop Down 1: "Pit Inspected" - Possible answers: YES, NO

               

              If Drop Down 1 is Yes,

              Required - Text Box 1: "Time Inspected"

               

              If No, Not Required - Text Box 1.

               

              If Drop Down 1 is Yes,

              Required - all of the following 13 Drop Downs must have either Yes or No selected:

               

              Drop Down 2: "Wet Conditions" - Possible answers: YES, NO

              Drop Down 3: "Over-head Power" - Possible answers: YES, NO

              Drop Down 4: "Utility Crossing" - Possible answers: YES, NO

              Drop Down 5: "Adjacent Structure" - Possible answers: YES, NO

              Drop Down 6: Cracks in side of pit - Possible answers: YES, NO

              Drop Down 7: "Spoils 2' from edge" - Possible answers: YES, NO

              Drop Down 8: "Exposed to Vibration" - Possible answers: YES, NO

              Drop Down 9: "Surface Water Present" - Possible answers: YES, NO

              Drop Down 10: "Vehicular Traffic" - Possible answers: YES, NO

              Drop Down 11: "Previously disturbed soil" - Possible answers: YES, NO

              Drop Down 12: "Adjacent excavation" - Possible answers: YES, NO

              Drop Down 13: "Cracks on top of trench" - Possible answers: YES, NO

              Drop Down 14: "Confined space exposure" - Possible answers: YES, NO

               

              If Drop Down 14: "Confined Space Exposure" has answer set to YES

              then, Text Box 2 is Required: "If Yes, What Type"

              • 4. Re: How to set If/Then Logic for Drop Downs ?
                SSCSteven Level 1

                This sounds interesting - what is the purpose of the temporary button? Is the idea that you Delete the Temp button, once your form is finalized and ready to be sent out?

                 

                When you say "Radio Buttons" can easily be reset - how so? How do you reset a group of radio buttons so that none are selected?

                • 5. Re: How to set If/Then Logic for Drop Downs ?
                  George_Johnson MVP & Adobe Community Professional

                  Yes, that's the reason for the button.

                   

                  With JavaScript you can simply set the value to "Off". If none of the radio button is configured to be "Selected by default", then using a Reset Form action or the resetForm JavaScript will result in none being selected.

                  1 person found this helpful
                  • 6. Re: How to set If/Then Logic for Drop Downs ?
                    SSCSteven Level 1

                    Thanks!

                     

                    Do you happen to know how to write a script so that additional Drop Downs are required, when 1 Drop Down is set to Yes - and additional Drop Downs are not required, when Drop Down is set to No.

                     

                    Thank you!

                    • 7. Re: How to set If/Then Logic for Drop Downs ?
                      try67 MVP & Adobe Community Professional

                      As the custom validation script of "Drop Down 1" you can enter something like this:

                      this.getField("Drop Down 2").required = (event.value=="Yes");

                      this.getField("Drop Down 3").required = (event.value=="Yes");

                      this.getField("Drop Down 4").required = (event.value=="Yes");

                      etc/