1 Reply Latest reply on Oct 22, 2012 8:55 PM by DimitriM

    Nested Dependent Dropdowns in Acrobat

    ANewGirl

      Firstly I am an exceptionally new user of JavaScript. My knowledge has been entirely gleaned by using examples of code which others have provided and I only started a few days ago.

       

      I'm trying to create a form that helps University researchers select two types of Australian research codes for a form they need to fill out and submit to my office.

      • Field of Research (FoR - a total of 1239 six-digit codes); and
      • Socioecomomic Objective codes (SEO - a total of 847 six-digit codes).

       

      The codes are broken down into 22(FoR) and 17(SEO) broad categories, and then broken down again into more specific fields, which are then broken down into very specific topics.

      i.e.

      82DIVISION 82 PLANT PRODUCTION AND PLANT PRIMARY PRODUCTS
      8201 Forestry
      820101Hardwood Plantations
      820102Harvesting and Transport of Forest Products
      820103Integration of Farm and Forestry
      820104Native Forests
      820105Softwood Plantations
      820199Forestry not elsewhere classified

       

      Basically for both FOR and SEO codes I want users to be able to:

      1. select a category from a first drop down box (e.g,82 Plant production and Plant primary products)
      2. then further narrow the options using a second drop down box (e.g, 8201 Forestry)
      3. finally selecting the specific code they want using a third drop down list (e.g, 820101 Hardwood Plantations)

       

      The following article has proved very useful in achieving the first two steps in my process.

      http://forums.adobe.com/message/3012567

      But I still cannot make the third box work. Im not sure if I should be nesting my data structure under what I already have, or providing a second set of data, nor how I am to reference the first box to the second and the second to the third (if that makes sense).

       

      Here is an extract of my code so far. I've only started on FOR and I hoped once I had the structure right I could duplicate it for the SEO codes. The code below works for the first two boxes, but the third box just duplicates the values for the second box. Thanks for any assistance you can provide.

      ------------------

      myFORCategory1Values =

      [

          "",

          "DEFENCE",

          "PLANT PRODUCTION AND PLANT PRIMARY PRODUCTS",

          "ANIMAL PRODUCTION AND ANIMAL PRIMARY PRODUCTS",

          "MINERAL RESOURCES (EXCL. ENERGY RESOURCES)",

          "ENERGY",

          "MANUFACTURING",

          "CONSTRUCTION",

          "TRANSPORT",

          "INFORMATION AND COMMUNICATION SERVICES",

          "COMMERCIAL SERVICES AND TOURISM",

          "ECONOMIC FRAMEWORK",

          "HEALTH",

          "EDUCATION AND TRAINING",

          "LAW, POLITICS AND COMMUNITY SERVICES",

          "CULTURAL UNDERSTANDING",

          "ENVIRONMENT",

          "EXPANDING KNOWLEDGE",

      ];

       

      //Populate the values to box1.

       

      this.getField("FORCategory1").setItems(myFORCategory1Values);

       

       

      //Define what has to be shown in box2 when box1 value is selected

       

      var FieldData =

      {

          "DEFENCE":

          [

              "",

              "Air Force",

              "Army",

              "Command, Control and Communications",

              "Emerging Defence Technologies",

              "Intelligence",

              "Logistics",

              "National Security",

              "Navy",

              "Personnel",

              "Defence not elsewhere classified"

          ],

          "PLANT PRODUCTION AND PLANT PRIMARY PRODUCTS":

          [

              "",       

              "Forestry",

              "Horticultural Crops",

              "Industrial Crops",

              "Summer Grains and Oilseeds",

              "Winter Grains and Oilseeds",

              "Harvesting and Packing of Plant Products",

              "Environmentally Sustainable Plant Production",

              "Other Plant Production and Plant Primary Products"

          ]

      };

       

       

      //Define what has to be shown in box3 when value in box 2 is selected (this is where I'm stuck, im not sure if this should even exisit)

       

      var SpecFieldData =

      {

      //Defence (Defence only has two levels, not three, so its a bit different)

          "Air Force":["Air Force"],

          "Army":["Army"],

          "Command, Control and Communications":["Command, Control and Communications"],

          "Emerging Defence Technologies":["Emerging Defence Technologies"],

          "Intelligence":["Intelligence"],

          "Logistics":[ "Logistics"],

          "National Security":["National Security"],

          "Navy":["Navy"],

          "Personnel":["Personnel"],

          "Defence not elsewhere classified":["Defence not elsewhere classified"],

      //Plant

          "Forestry":

          [

              "Hardwood Plantations",

              "Harvesting and Transport of Forest Products",

              "Integration of Farm and Forestry",

              "Native Forests",

              "Softwood Plantations",

              "Forestry not elsewhere classified"

          ],

          "Horticultural Crops":

          [

              "Almonds",

              "Berry Fruit (excl. Kiwifruit)",

              "Citrus Fruit",

              "Hops",

              "Kiwifruit",

              "Macadamias",

              "Mushrooms and Truffles",

              "Olives",

              "Ornamentals, Natives, Flowers and Nursery Plants",

              "Pome Fruit, Pip Fruit",

              "Stone Fruit",

              "Table Grapes",

              "Tree Nuts (excl. Almonds and Macadamias)",

              "Tropical Fruit",

              "Vegetables",

              "Horticultural Crops not elsewhere classified"

          ]

      };

       

      //Set the values of box2

      function SetFieldValues(cFieldValues,cSpecFieldValues)

      {

      this.getField("FORField1").setItems(FieldData[cFieldValues])

      this.getField("FORSpecField1").setItems(SpecFieldData[cSpecFieldValues])

      }