8 Replies Latest reply on Jun 30, 2015 9:14 AM by jasminep41032624

    How Do You Append Text from Multiple Drop Down Menus?

    jasminep41032624

      I have a PDF that will have 10 drop down menus. What I want to do is when an option in drop down #1 is selected, text in a different field is created. If an option is drop down #2 is selected, I want to append the text in the field mentioned previously and ADD on to it. Here is my example which might clarify this a little further:

       

      If the user selects #1 in the first drop down menu then the text field "Model Description" is filled in with text like "#1: This model is aimed to have a high return with low risk."

      Then if the user selects #3 from the second drop down menu the text field will still contain the original text from above and will add the following "#3: This model consists of stocks, bonds, and ETFs." So the end result in the text field would look like this:

       

      #1: This model is aimed to have a high return with low risk.

      #3: This model consists of stocks, bonds, and ETFs.

       

      I would also like the existing text in the PDF to auto-adjust to make or remove space on the form so there isn't a bunch of white space. I'm not sure if I would have to hide or make the text field invisible? I've never used JavaScript before so any help is greatly appreciated!

       

      Thank you!

        • 1. Re: How Do You Append Text from Multiple Drop Down Menus?
          gkaiseril MVP & Adobe Community Professional

          Have you assigned a value to the default value for the drop down boxes that is not be included?

           

          If so use an array and insert only values that are not  equal to the default value. Then join the elements of the array separated by ", ". if there are more than 1 element in the array, the first element of the array if there is only one item in the array then use that value.

           

          var aText = new Array();

          var aFields = new Array("Dropdown1", "Dropdown2", "Dropdown3");

          for(var i = 0; i < aFields.length; i++) {

          if(this.getField(aFields[i]).value != this.getField(aFields[i]).defaultValue) aText.push(this.getField(aFields[i]).value);

          }

          event.value = "";

          if(aText.length == 1) event.value = aText[0];

          if(aText.length > 1) event.value = aText.join(", ");

          • 2. Re: How Do You Append Text from Multiple Drop Down Menus?
            jasminep41032624 Level 1

            Thanks - There isn't a default value in the dropdown menus. Should there be?

             

            Also, where do I input this code? In the Format properties of each drop down menu or in the Document Javascripts (I'm thinking here, but want to double-check)? I'm very new to all of this.

             

            Thanks again!!!

            • 3. Re: How Do You Append Text from Multiple Drop Down Menus?
              gkaiseril MVP & Adobe Community Professional


              There is. It is the selection when the form is cleared..

               

              Usually a space.

               

              If one does not have a default value for the field what is selected when there has been no selection made?

               

              If one were to put the code in the drop down fields each field would need to have code. If one puts in the text field being updated, then the code is entered only once.

              • 4. Re: How Do You Append Text from Multiple Drop Down Menus?
                jasminep41032624 Level 1

                Just a blank drop down menu. Is that the space you are referring to?

                • 5. Re: How Do You Append Text from Multiple Drop Down Menus?
                  gkaiseril MVP & Adobe Community Professional

                  Yes. That is it. With JavaScript, one could eliminate the space.

                  • 6. Re: How Do You Append Text from Multiple Drop Down Menus?
                    jasminep41032624 Level 1

                    I think I'm getting it, but can you tell me where to put the code you provided? Is it in the Document Javascript? I already have an action created to execute the following JavaScript when someone selects an option from any drop down menu:

                     

                    var one = this.getField("ModelList1");

                    var two = this.getField("ModelDescription");

                    if(two.value==''||two.value==null){two.value=one.value;};

                     

                    I have the following setup in the Document Javascript section to set the value of the text box to match the corresponding description of the model:

                     

                    var ModelInfo = { "Model 1": { ModelDescription: "#1: This model is aimed to have a high return with low risk." },

                                              { "Model 2": { ModelDescription: "#2: This model is an actively managed mutual fund portfolio designed minimize risk." },

                                              { "Model 3": { ModelDescription: "#3: This model consists of stocks, bonds, and ETFs." }};

                    function SetFieldValues (cModelSelection) {

                                             this.getField("ModelDescription").value = ModelInfo[cModelSelection].ModelDescription;}

                     

                    So I'm not sure where your code would go or if the existing code I have would screw up what you provided. THANK YOU!!!!

                    • 7. Re: How Do You Append Text from Multiple Drop Down Menus?
                      gkaiseril MVP & Adobe Community Professional

                      I would put in the Custom JavaScript Calculation for the text field. That why there is only one place to enter the code and edit the code for errors.

                       

                      Another approach would be to create a function that would combine the values of the fields and then call that function and use the return string from the function to populate the text field.

                      • 8. Re: How Do You Append Text from Multiple Drop Down Menus?
                        jasminep41032624 Level 1

                        You are so helpful! How would we do the second option? I think that would work the best with what I'm trying to achieve.