11 Replies Latest reply on Jan 9, 2012 10:11 AM by Ida Eve

    How do you populate 1 text box with multiple dropdown values

    Ida Eve Level 2

      I can populate a text box with a value from a dropdown, however if I have 2 dropdown values going to the same text box (multi-line), the second dropdown value removes the first value.

       

      (Similar code on Dropdown 1 and Dropdown 2)

      Change Event - JavaScript

       

      if(xfa.event.newText == 'No'){

      form1.page1.subform2.description.rawValue="No location listed";

      }

      if(xfa.event.newText == "Partial location"){

      form1.page1.subform2.description.rawValue="Partial location listed";

      }

       

      Do I have to Concat the fields in the 1 text field to get it to list multiple dropdown values, and if so how do I do that?

       

      Thanks in advance for your help.

        • 1. Re: How do you populate 1 text box with multiple dropdown values
          Steve L Walker Level 5

          Is this what you are after?

           

          // form1.page1.subform1.tf::calculate - (JavaScript, client)

           

          if (form1.page1.subform1.color.selectedIndex != -1 && form1.page1.subform1.fruit.selectedIndex != -1) {

                    this.rawValue = form1.page1.subform1.color.rawValue + "\n" + form1.page1.subform1.fruit.rawValue;

          }

          else {

                    if (form1.page1.subform1.color.selectedIndex != -1 && form1.page1.subform1.fruit.selectedIndex == -1) {

              this.rawValue = form1.page1.subform1.color.rawValue;

                    }

                    else {

              if (form1.page1.subform1.color.selectedIndex == -1 && form1.page1.subform1.fruit.selectedIndex != -1) {

                this.rawValue = form1.page1.subform1.fruit.rawValue;

              }

                    }

          }

           

          Steve

          1 person found this helpful
          • 2. Re: How do you populate 1 text box with multiple dropdown values
            Ida Eve Level 2

            Thanks Steve for your help on this, you are amazing!

             

            That is close.  I am actually trying to display specific values from the dropdown. 

             

            So for your example, lets say I want just Red and Green values from the color field and Apples and Pears from the Fruit field to populate the textbox.  I also want to change the drop down value of "Red" to say "Ruby Red" to in the Text box.  Is that possible?

            • 3. Re: How do you populate 1 text box with multiple dropdown values
              Ida Eve Level 2

              YAY - I got it figured out!

               

              On Color Drop Down - Change Event, JavaScript

               

              if (xfa.event.newText == 'Red') {

                   form1.page1.subform1.textbox.rawValue="Ruby Red";

              }

              if (xfa.event.newText == 'Green'){

                   form1.page1.subform1.textbox.rawValue="Light Green";

              }

               

              On Fruit Drop Down - Change Event, JavaScript

               

              if (xfa.event.newText == 'Apple') {

                   form1.page1.subform1.textbox.rawValue="Granny Smith";

              }

              if (xfa.event.newText == 'Pear'){

                   form1.page1.subform1.textbox.rawValue="Bartlett";

              }

               

              On Text Box - Calculate Event, JavaScript

              this.rawValue = form1.page1.subform1.color.rawValue + "\n" + form1.page1.subform1.fruit.rawValue; 

               

              Thank you Steve for pointing me into the right direction.

              • 4. Re: How do you populate 1 text box with multiple dropdown values
                Ida Eve Level 2

                It works for only a few drop down values, if I get more than 6 going it displays only the last drop-down value.  What am I doing wrong?

                • 5. Re: How do you populate 1 text box with multiple dropdown values
                  Steve L Walker Level 5

                  If you send the form to stwalker.adobe@gmail.com I'd be happy to take a look.

                   

                  Steve

                  • 6. Re: How do you populate 1 text box with multiple dropdown values
                    Ida Eve Level 2

                    Changed the event from Change to Calculated and then the value type "Calculated - Read only" to "Calculated - User can override" and it didn't work.  Text box is blank.

                    • 7. Re: How do you populate 1 text box with multiple dropdown values
                      Ida Eve Level 2

                      HUMMMMM – How would I add the dropdown fields to the text box?

                       

                      Eve Tracy

                      • 8. Re: How do you populate 1 text box with multiple dropdown values
                        Steve L Walker Level 5

                        You need to remove the script from each drop-down change event and put all the script on the description calculate event. For example,

                         

                        // form1.NonCompliancePage.subform2.description::calculate - (JavaScript, client)

                         

                        var str = "";

                         

                        if (form1.recordKeepingPage.RecordKeeping.rk_BusName.rawValue == "Required Records - No business name listed" || form1.recordKeepingPage.RecordKeeping.rk_BusName.rawValue == "Required Records - Partial business name listed") {

                                  if (form1.recordKeepingPage.RecordKeeping.rk_BusName.rawValue == "Required Records - No business name listed") {

                                            str = "Required Records-No business name listed" + "\n";

                                  }

                                  else {

                                            str = "Required Records - Partial business name listed" + "\n";

                                  }

                        }

                         

                        if (form1.recordKeepingPage.RecordKeeping.rk_StAddress.rawValue == "No" || form1.recordKeepingPage.RecordKeeping.rk_StAddress.rawValue == "Partial address" || form1.recordKeepingPage.RecordKeeping.rk_StAddress.rawValue == "P.O Box only") {

                                  if (form1.recordKeepingPage.RecordKeeping.rk_StAddress.rawValue == "No") {

                                            str =  str + "Required Records-No address of the application listed" + "\n";

                                  }

                                  else {

                                            if (form1.recordKeepingPage.RecordKeeping.rk_StAddress.rawValue == "Partial address") {

                                                      str = str + "Required Records-Partial address listed" + "\n";

                                            }

                                            else {

                                                      str = str + "Required Records-PO Box only listed" + "\n";

                                            }

                                  }

                        }

                         

                        this.rawValue = str;

                         

                        Steve

                        • 9. Re: How do you populate 1 text box with multiple dropdown values
                          Ida Eve Level 2

                          Thank you so much!  This is exactly what I was wanting to do, you are Amazing!

                          • 10. Re: How do you populate 1 text box with multiple dropdown values
                            Ida Eve Level 2

                            I have another question regarding the script to populate a text box with multiple dropdown values. 

                             

                            How do you save the form state (keep the page visible after it has been saved)?  This form will be connected to a signature pad, so it has to be certified and preserve scripting changes to form when saved is set to manually.  

                             

                            I can save the form state of several other hidden pages using this code in the initialize event:

                             

                            if

                            (this.rawValue==1)

                            {subformName.presence="visible";}

                            else

                            {subformName.presence="hidden";}

                             

                             

                            However, since I have multiple fields writing to a text box using the calculated event, I can't seem to save the form state using the code above. 

                             

                            Please help, I have been searching forums and can not find a solution to this one.

                            • 11. Re: How do you populate 1 text box with multiple dropdown values
                              Ida Eve Level 2

                              Solved:

                               

                              Place this script in the subform root level in the FormReady event -JavaScript.

                               

                              var oList = this.getDeltas ();

                              for (i=0; i < oList.length; i ++)

                              {

                                 var oDelta = oList.item(i);

                                 oDelta.restore ();

                              }

                               

                              Answer was found at http://forms.stefcameron.com/2008/09/29/restoring-the-of-your-form/