4 Replies Latest reply on Mar 21, 2008 12:17 PM by gkaiseril

    Populate 2nd combo box based on value selected in 1st combo box

    evil8 Level 1
      I am still using Acrobat 6 though I may be upgrading soon to Acrobat 8. I have a form with two combo boxes, the first "state" has values of MN and WI. Based on which value the user picks I would like to populate a "county" combo box with lists of counties that we deal with.

      Thanks,

      Gene
        • 1. Re: Populate 2nd combo box based on value selected in 1st combo box
          gkaiseril MVP & Adobe Community Professional
          See the 2 part article by Thom Parker:

          Programming List and Combo fields in Acrobat and LiveCycle forms Part 1
          by Thom Parker

          http://www.acrobatusers.com/tutorials/2007/js_list_combo_livecycle/

          Programming List and Combo fields in Acrobat and LiveCycle forms- Part 2
          by Thom Parker,

          http://www.acrobatusers.com/tutorials/2007/10/list_and_combo_in_lc/
          • 2. Re: Populate 2nd combo box based on value selected in 1st combo box
            evil8 Level 1
            Thanks! I'll give 'em a good read.
            • 3. Re: Populate 2nd combo box based on value selected in 1st combo box
              evil8 Level 1
              Thanks Geo!  This is working great:<br /><br />// Master List of Lists<br />// Each entry in this object listeral is the name of a State<br />//Manually enter the State Names into the state field combo box<br />// The associated value is the item list, where each item is a name value pair, [<County>] <br /><br />var oStateNames = { <br />                       MN: [ ["-"], ["St. Louis"], ["Carlton"], ["Pine"],["Cook"]],<br />                       WI: [ ["-"], ["Douglas"], ["Bayfield"], ["Burnette"],["Ashland"]],<br />                     };        <br /><br />//SetCountyEntries() on keystroke entry in state field<br />function SetCountyEntries()<br />{<br />   if(event.willCommit)<br />   {<br />      // Get the new counties list from the Master List<br />      // Since the selection is being committed,<br />      // event.value contains the State name<br />      var lst = oStateNames[event.value];<br />      // Clear the county list if there are no counties for the selected state<br />      if( (lst != null) && (lst.length > 0) )<br />         this.getField("ee.address.county").setItems(lst);<br />      else<br />         this.getField("ee.address.county").clearItems();<br />   }<br />}<br /><br />Now how would I change the master list to add a list of zip codes based on the county value selected?
              • 4. Re: Populate 2nd combo box based on value selected in 1st combo box
                gkaiseril MVP & Adobe Community Professional
                One can set the option and export value using an arry:<br /><br />// document level script<br />// Master List of Lists <br />// Each entry in this object listeral is the name of a State <br />//Manually enter the State Names into the state field combo box <br />// The associated value is the item list, where each item is a name value pair, [<County> and [county code, zip code]] <br /><br />// state: ["county name", ["county code", "zip code"]]<br />var oStateNames = {MN: [["-", ["", ""] ], <br />                       ["St. Louis", ["MNStl", "55001"] ], <br />                       ["Carlton", ["MNSCrl", "55002"] ], <br />                       ["Pine", ["MNPin", "55003"] ],<br />                       ["Cook", ["MNCok", "55004"] ] <br />                       ], <br />                   WI: [["-", [" ", " "] ],<br />                        ["Douglas", ["WIDou", "55005"] ] ,<br />                        ["Bayfield", ["WIBay", "55006"] ],<br />                        ["Burnette", ["WIBur", "55007"] ],<br />                        ["Ashland", ["WIAsh", "55008"] ]<br />                       ]<br />                     }; <br /><br />//SetCountyEntries() on keystroke entry in state field <br />function SetCountyEntries() <br />{ <br />   if(event.willCommit) <br />   { <br />      // Get the new counties list from the Master List <br />      // Since the selection is being committed, <br />      // event.value contains the State name <br />      var lst = oStateNames[event.value]; <br />      // Clear the county list if there are no counties for the selected state <br />      this.getField("ee.address.county").clearItems();<br />      this.resetForm(["ee.address.code", "ee.address.zip"]);<br />      if( (lst != null) && (lst.length > 0) )<br />           this.getField("ee.address.county").setItems(lst); // set opiton and export value<br />   } <br />} <br />//  end document level script<br /><br />For the combo box "ee.address.county" one can create an array from the export value to populate the county code and zip code<br /><br />// custom keystroke for county combo box<br />if(event.willCommit & event.value != "") {<br />// split county and zip codes<br />var aCodes = this.getField(event.target.name).value.split(",");<br />this.getField("ee.address.code").value = aCodes[0];<br />this.getField("ee.address.zip").value = aCodes[1];<br />}<br />// end custom key stroke code