25 Replies Latest reply: Jan 24, 2012 9:35 AM by ShellJ6608 RSS

    Populate  Text Field Based On Drop-Down List Selection

    Community Member
      I'm trying to set up a form so that a text field will populate with default text (that could later be edited by the end user) based on a users previous drop-down selection.

      For example:

      The end user is putting together a proposal for a client and is able to choose the type of proposal or service from a drop-down list. Once the user makes a selection from the drop-down list a text field is populated with default text describing the service.

      The only catch is that the end user would need to be able to edit the default text. An example would be if an individual purchased a car but all the specific features and/or accessories could be added into the default text as necessary based on the purchasers desired upgrades. The common or universal features of the car would, however, show up as the default text.

      Would this scenario be possible through the use of XML? Any tips on how I can accomplish this would be much appreciated.
        • 1. Re: Populate  Text Field Based On Drop-Down List Selection
          Community Member
          I'm finding it a little difficult to grasp what you're trying to accomplish so here's what I think you're asking for: You have a form which has a drop down list and a text field. When the user selects an item in the drop down list, you would like the text field to be automatically populated with an initial (default) value describing the selected item which the user could then edit (in the text field) to suit their specific needs.

          If that's correct, then you would need just a little bit of script on the drop down list's Change event which would determine the item selected by the user and would set the text field's value to that which pertains to the new selection.

          Let's say the text field is named "TextField1" and that you've associated a value to each item in the drop down list so that the selection is easy to compare in order to determine which initial (default) value to set in the text field. In your drop down list's Change event, you could use the following script (in JavaScript):
          var sNewSel = this.boundItem(xfa.event.newText);
          

          switch (sNewSel)
          {
            case "1": // car purchase
              TextField1.rawValue = "Basic features:\n- frame\n- wheels\n- glass";
              break;

            case "2": // other purchase
              TextField1.rawValue = "Basic features..."
              break;

            default: // unknown value -- do nothing
              break;
          }


          Here we see the use of the xfa.event.newText property in order to retrieve the text associated to the item which was just selected in the drop down list. Then we use the boundItem method of the drop down list (this) in order to retrieve the value that we associated to that item. Finally, we check the value and assign multi-lined values (note the "\n" characters in the strings which represent new lines) to our multi-lined TextField1 field's value.

          To help illustrate this, I've create a small sample form which uses the code I described above with the added feature that the text field is disabled until the user makes a selection in the drop down list.

          Stefan
          Adobe Systems
          • 2. Re: Populate  Text Field Based On Drop-Down List Selection
            Community Member
            Thanks so much Stefan! You were right on target and it works like a charm.
            • 3. Re: Populate  Text Field Based On Drop-Down List Selection
              Community Member
              Using Adobe LifeCycle Designer for Adobe 8 I'm trying to populate a text field with multiple entries from a drop down list. I managed to be able to populate the text field for a single selection from the drop down list but am having trouble getting it to allow multiple selections from the drop down list to populate the text field keeping all of the selections within it. When I click another selection from the drop down list the first entry that populated the text field is replaced by the new entry, I need it to maintain all entries entered...please help.
              • 4. Re: Populate  Text Field Based On Drop-Down List Selection
                GKaiseril ACP/MVPs
                Your post is different form the Original Post and should be a separate post of it's own since it maybe lost and if the OP subscribes to this post by email, that person will be flooded with responses to your post.

                In Acrobat, the Drop Down Box/List field does not support multiple selections only Combo List field does when that option is set for that field. Looking at the Drop Down List, I did not see an option to enable multiple item selection. Also LC D does not support the Acrobat JS "currentValueIndices" field property that is used to recover the multiple item selection array nor does it support the "getItemAt" field property that is used to get a selected entry from the combo list. So it appears this might not be possible.

                For more information about Scripting in LC D see:

                Scripting languages and resources (LiveCycle Designer 8.x)
                http://www.adobe.com/cfusion/search/index.cfm?loc=en_us&term=livecycle+javascript
                • 5. Re: Populate  Text Field Based On Drop-Down List Selection
                  Community Member
                  I am new Adobe livecycle developer , my knowledge is Oracle and Sql , plSql . I want to design an adobe form, for which I have 2 drop down lists , one for all ministries , the other one is for all directorates which related to the selected ministry. The scenario is as follows:
                  The user will pick a ministry from the 1st drop down list, then for the 2nd dropdown, the list of all directorates that are belongs to the selected ministry should appear in order he can select the specified directory from the dropdown list. (no need for buttons).
                  I had tried the Stefan Camerons procedure in connecting a form to Db, and selecting specific record from a data base , the dropdown "Pick a Category" field is not working, also I had tried to copy his script into my form ,still is not working. Is there any method ? or maybe something I need to add to my script .

                  I am using adobe live cycle designer 7.1
                  Adobe reader is 7.0
                  the file is saved as pdf
                  data connection informations in the form are as follows :
                  1-DataConnection1.
                  Using OLEDB
                  database name is : Financial_DB_Forms (on the server)
                  OLEDB provider is :Microsoft OLEDB provider for SQL Server
                  Server : MOFNEO
                  Connecting string : Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Financial_DB_Forms;Data Source=MOFNEO;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=CPU-0900;Use Encryption for Data=False;Tag with column collation when possible=False
                  Table1 : Financial_Form_Ministry ( contains all ministries numbers and description)

                  2-DataConnection2. (same info. As above )
                  Table2 : Financial_Form_Directorate ( contains of all directorates for all ministries and description) .

                  Also can you please send me a telephone number and e-mail of any adobe developer that I can call him if I need any assistance .

                  Your help will be much appreciated,
                  Thanks,
                  Mariam Kadhimi
                  Tel : +973-39597575 (mobile)
                  Tel : +973-17575560 (Office)
                  Kingdom of Bahrain
                  • 6. Re: Populate  Text Field Based On Drop-Down List Selection
                    Community Member
                    Stefan -

                    I had itially looked for a way to simply wrap text in a drop down list as I thought that would be the simplest way to do what the client requested (have a list of standard options to choose from but still enable custom entries).

                    Since I couldn't find a way to wrap my dropdown text, I tried to modify your sample from but I can't get it to work for me, and I'm not sure if it's the best option for what the client needs.

                    In addition to not being able to make the drop down affect the text box, how would I get the drop down to hide after exit? I will want to have this pairing repeat (for a total of 6 or 8 text boxes) and want to only print/see the text boxes, and not the drop downs after the text is entered.

                    My test doc is at www.scottsdaleaz.gov/Assets/documents/airport/TESTING-StipDropDownSelection.pdf

                    ' Here's how I modified what you gave:

                    var sNewSel = this.boundItem(xfa.event.newText);
                    var bEnableTextField = true;

                    switch (sNewSel)
                    {
                    case "1": // Changes Require Approval Prior to Development Review
                    Stipulation1.rawValue = "Changes to the development plans anytime after airport staff has signed this
                    form requires additional airport approval of the change prior to development review
                    board hearing.";
                    break;

                    case "2": // FAA form 7460-1
                    Stipulation1.rawValue = "Developer must demonstrate that an FAA form 7460-1 was completed unless
                    exemptions apply."
                    break;

                    case "3": // Noise Disclosure
                    Stipulation1.rawValue = "Applicant must demonstrate aircraft noise and overflight activity disclosure to
                    proposed occupants."
                    break;

                    case "4": // Fuel Dispensing and Storage
                    Stipulation1.rawValue = "Fuel dispensing and storage proposed for development projects must have
                    specific documented airport review and approval. Storage and dispensing of fuel
                    must be in accordance with Airpark Rules and Regulations."
                    break;

                    case "5": // Significant Changes Required Additional Review
                    Stipulation1.rawValue = "Significant changes to this project require additional project review by airport
                    staff."
                    break;

                    case "6": // Approval Valid for 1 Year
                    Stipulation1.rawValue = "This approval is valid for up to one year from the date it was signed. Further
                    review is not required prior to final plans approval unless substantial revisions are
                    made to the development plans anytime after the date this form was approved."
                    break;

                    default: // unknown value -- do nothing
                    bEnableTextField = false;
                    break;
                    }

                    Thanks - This is the first time I've had to use LiveCycle instead of the basic forms tools.

                    -----------------
                    Beckye Frey
                    Customer Relations Specialist
                    480-312-2743
                    bfrey@scottsdaleaz.gov

                    City of Scottsdale
                    Planning & Development Services Department
                    7447 E Indian School Road, Ste 105
                    Scottsdale, AZ 85251
                    • 7. Re: Populate  Text Field Based On Drop-Down List Selection
                      Community Member
                      Is there any way that someone could explain it to a beginner?

                      Dropdown list > address info is based on list selection (address info is multiple lines "address, city, st, zip, phone"

                      So user is filling out a form, selects recipient, and the address info + phone populates on it's on (into a text box) based on the item selected in the drop down.
                      • 8. Re: Populate  Text Field Based On Drop-Down List Selection
                        Help.

                        Could you look at the following and see what I am missing? I have copied Stefan's example. I have modified it within the sample pdf that he posted and it works great. I have now tried to move it to my development form and I cannot get the textfield to populate with the drop down selection. I think it may be in naming convention, but not sure where or how to track down my problem. I have put them on the same subform, but that did not work.

                        Thanks,

                        Stan

                        ----- form1.form2.BIP_Subform.EquipList::change: - (JavaScript

                        var sNewSel = this.boundItem(xfa.event.newText);
                        var bEnableTextField = true;

                        switch (sNewSel)
                        {
                        case "1": // AN
                        TextField10.rawValue = "Face Shield\nGoggles\nChemical Gloves\nAir Supplied Respirator\nChemical Green Suit\nChemical Boots";
                        break;

                        case "2": // BUO
                        TextField10.rawValue = "Face Shield\nGoggles\nChemical Gloves\nAir Supplied Respirator\nChemical Green Suit\nChemical Boots";
                        break;

                        //I have 32 cases, but left them out here)

                        default: // unknown value -- do nothing
                        bEnableTextField = false;
                        break;
                        }

                        if (bEnableTextField)
                        {
                        TextField10.access = "open"; // enable field
                        TextField10.caption.font.fill.color.value = "0,0,0"; // set caption to black
                        }

                        My textfield info is:

                        ----- form1.form2.BIP_Subform.TextField10::change: - (JavaScript, client) --------------------------
                        • 9. Re: Populate  Text Field Based On Drop-Down List Selection
                          Community Member
                          great stuff here.

                          Can this be applied to work on a second DROP DOWN LIST instead of a text field.

                          Simply put, I would like to populate a second drop down list based on chosen selections from a first drop down list.

                          thanks
                          • 10. Re: Populate  Text Field Based On Drop-Down List Selection
                            Community Member
                            Hi Stefan,

                            I'm using you code that you posted first. How do I amend it so that the second text box is actually another drop down list?

                            Thanks, Justin
                            • 11. Re: Populate  Text Field Based On Drop-Down List Selection
                              Community Member
                              Hi Redcoat,

                              Were you able to figure out how to make the second list a drop down menu?

                              Thanks, Justin
                              • 12. Re: Populate  Text Field Based On Drop-Down List Selection
                                Community Member
                                Dear Stefan

                                Ref. you post above, I am trying to do a similar thing but no vain. Would you please help me?

                                I have a form where I have drop down list menu named as "Country" it shows names of many countries then I have another drop down list box with the name "cities" which has name of many cities....

                                In both of the above fields I have manually entered the names of the countries and cities respectively in the designer.

                                what I want is that when i select the specific country then all cities related to the country only show up in the "cities" drop down list box?

                                Is this possible in forms? I am using Life Cylce ES 8.2

                                please advise
                                Asim
                                • 13. Re: Populate  Text Field Based On Drop-Down List Selection
                                  Community Member
                                  I'm using Stefan's original example which is exactly what I am looking for but I'm having trouble moving the text field to a different page than the drop down. I want the user to select from the dropdown on page 1 and have that populate text fields on other pages. Is there additional script involved?
                                  • 14. Re: Populate  Text Field Based On Drop-Down List Selection
                                    Community Member
                                    I'm also trying to have it populate multiple text fields across multiple pages.
                                    • 15. Re: Populate  Text Field Based On Drop-Down List Selection
                                      Community Member
                                      Greetings,

                                      I've figured out how to string together different text and numeric fields into a single text field. My question is - is there any way i can have the results sent as a text message to a mobile phone? I simply want to send simple text to a mobile phone number.

                                      Any ideas?
                                      • 17. Re: Populate  Text Field Based On Drop-Down List Selection
                                        Community Member
                                        I am not sure this is what you are looking for but this is the script behind the drop down on change event and InsertNote1 is the text field being populated. The text field is also set to Calculated - Allow User Override.

                                        var sNewSel = this.boundItem(xfa.event.newText);
                                        var bEnableTextField = true;

                                        switch (sNewSel)
                                        {
                                        case "1": // Option 1
                                        InsertNote1.rawValue = "Text if option 1 is selected.";
                                        break;

                                        case "2": // Option 2
                                        InsertNote1.rawValue = "Text if option 2 is selected."
                                        break;

                                        case "3": // Option 3
                                        InsertNote1.rawValue = "Text if option 3 is selected."
                                        break;

                                        case "4": // Option 4
                                        InsertNote1.rawValue = "Text if option 4 is selected."
                                        break;

                                        case "5": // Option 5
                                        InsertNote1.rawValue = "Text if option 5 is selected."
                                        break;

                                        case "6": // Option 6
                                        InsertNote1.rawValue = "Text if option 6 is selected."
                                        break;

                                        case "7": // Option 7
                                        InsertNote1.rawValue = "Text if option 7 is selected."
                                        break;

                                        case "8": // Option 8
                                        InsertNote1.rawValue = "Text if option 8 is selected."
                                        break;

                                        default: // unknown value -- do nothing
                                        bEnableTextField = false;
                                        break;
                                        }

                                        if (bEnableTextField)
                                        {
                                        InsertNote1.access = "open"; // enable field
                                        InsertNote1.caption.font.fill.color.value = "0,0,0"; // set caption to black
                                        }
                                        • 18. Re: Populate  Text Field Based On Drop-Down List Selection
                                          Community Member
                                          I am trying to populate text fields with the same information, such as the name, address, and phone number. I want to know if there is way that I can do so, without having to use any outside coding. I don't need to populate complex information, just the basic. I guess my main purpose is to have that simple information populate throughout a form without having re-type such information throughout my 4-6page forms. Leaving me with less room for error.
                                          • 19. Re: Populate  Text Field Based On Drop-Down List Selection
                                            GKaiseril ACP/MVPs
                                            If you are going to set another field's value from a combo box or list you need to use some form a scripting.
                                            • 20. Re: Populate  Text Field Based On Drop-Down List Selection
                                              Community Member
                                              Hi how to generate the text field with the selection of an item in the combo box please help me if any one knows
                                              • 21. Re: Populate  Text Field Based On Drop-Down List Selection
                                                Community Member
                                                Stefan,

                                                I used your example in my table, which worked for the first row. However, I have a repeatable table with add and delete row buttons and the drop down only populates the first row.

                                                So, if I use the first drop down on the first row, it populates the first text field in the first row just fine. However, when I use the drop down on the next row, the first row gets updated instead of the second row text field. How do I tweak the nomenclature so that it knows to correspond to the same row?

                                                Dave
                                                • 22. Re: Populate  Text Field Based On Drop-Down List Selection
                                                  NellieJEndhoven Community Member

                                                  Hello Stefan,

                                                  I'm interested in the sample file you've created. Could you post it again?   I am also trying to populate textfields which are on different pages than the drop down lists, and have not succeeded. Can you help? Thanks.

                                                  thanks.

                                                  Nellie

                                                  • 23. Re: Populate  Text Field Based On Drop-Down List Selection
                                                    adragton Community Member

                                                    Stefan

                                                     

                                                    How do I get the PDF you devloped?

                                                    I need to see details of populating dropdown.

                                                     

                                                    Can you also "extend" the dropdown to other dependant dropdowns?

                                                    --one DD detrmining another DD, which then fills a text field(s)..

                                                     

                                                    -Allan

                                                    • 24. Re: Populate  Text Field Based On Drop-Down List Selection
                                                      shawnlippert Community Member

                                                      I am Working on a text field to, creating the form is no problem with a little Script.Right now Im just using an easy Drop Down Menu Generator.

                                                      http://www.javascriptsandmore.com/drop-down-menu-generator-software.html

                                                      • 25. Re: Populate  Text Field Based On Drop-Down List Selection
                                                        ShellJ6608 Community Member

                                                        Stefan,

                                                         

                                                        I am not very literate in scripting, but am learning as I go, so hopefully this will make sense. I am trying to get the drop down to generate a message in a text field, and if drop down is left blank, no message is shown. I used your example above to get my drop down to generate a text field, but it is not working. My drop down list is named "Security Deposit" and the text field is "Security". Here is what I entered in the script editor using Javascript and Change:

                                                         

                                                         

                                                         

                                                        var  (sNewSel=this.boundItem(xfa.event.newText);

                                                         

                                                        switch  (sNewSel)

                                                         

                                                        {

                                                        Security.rawValue

                                                        = " A security deposit has been paid to the Community. The deposit shall be applied to any damages done to Clubhouse or Community. If there are no damages, the payment will be returned to the Resident following inspection.";

                                                         

                                                         

                                                         

                                                        break;

                                                        default://unknown value--do nothing

                                                        ;

                                                         

                                                        }

                                                         

                                                        If you could please assist with this, I would really appreciate it!!

                                                        Thank you so much!