title: jquery dynamic dependent select from multidimensional array
body: <p>I am trying to have to have a form with two drop down select options that are populated from arrays. The first select has only one array, however depending on the selection, I want to populate the second with a specific multidimensional array. I am able to do them individually, but I am unable to pass the array name from the first selection to the function to populate the second.</p>
  
  <p>I am pretty new to javascript and jQuery 1.11.0 and would appreciate any assistance.</p>
  
  <p>Here is the code I am working with.</p>
  
  <pre><code>select name="aircraftList" id="aircraftList" onchange="showAircraft(this.selectedIndex)"
  
  select name="configWBList" id="configWBList"
  
  // values for AIRCRAFT
  // tnumber, acmodel, maxwt, f1arm, m1arm, r1arm, littarm, bag1max, fuel1kgmax, 
  /////////////////////////////////////////////////////////// 
  var aircraft = [
      ["Select Aircraft", "", "", "", "", "", "", "", "", ""],
      ['N901AH', "Agusta A109E", 3000, 1585, 2455, 3200, 5300, 3200, 150, 480],
      ['N902AH', "Agusta A109E", 3000, 1585, 2455, 3200, 5300, 3200, 150, 480],
      ['N903AH', "Agusta A109E", 3000, 1585, 2455, 3200, 5300, 3200, 150, 480],
      ['N904AH', "Agusta A109E", 3000, 1585, 2455, 3200, 5300, 3200, 150, 480],
      ['N905AH', "Agusta A109E", 3000, 1585, 2455, 3200, 5300, 3200, 150, 480],
      ['N907AH', "Agusta A109E", 3000, 1585, 2455, 3200, 5300, 3200, 150, 480]
  ];
  
  // values for AC N901AH
  /////////////////////////////////////////////////////////// 
  var N901AH = [
      ["Select a Configuration", "Select Config", "Select Config"],
      ["6 PAX STANDARD SEATS OFFSHORE", 2205.61, 3485.69],
      ["DUAL CONTROLS INSTALLED", 2207.81, 3483.76],
      ["VIP SEATS INSTALLED", 2212.11, 3483.75],
      ["VIP SEATS, DUAL CONTROLS INSTALLED", 2214.31, 3481.83],
      ["ONE LITTER KIT INSTALLED", 2213.91, 3483.50],
      ["ONE LITTER, DUAL CONTROLS INSTALLED", 2216.11, 3481.58],
      ["6 PAX STANDARD SEATS, VESTS REMOVED", 2196.81, 3489.83],
      ["VIP SEATS INSTALLED, VEST REMOVED", 2203.31, 3487.87],
      ["ONE LITTER INSTALLED, VESTS REMOVED", 2207.31, 3487.02],
      ["TWO LITTER INSTALLED", 2222.21, 3481.32],
      ["TWO LITTER, DUAL CONTROLS INSTALLED", 2224.41, 3479.41],
      ["VIP SEATS, DUAL CONTROLS INSTALLED, VESTS REMOVED", 2205.51, 3485.93],
      ["ONE LITTER, DUAL CONTROLS INSTALLED, VESTS REMOVED", 2209.51, 3485.09],
      ["TWO LITTER, DUAL CONTROLS INSTALLED, VESTS REMOVED", 2220.01, 3482.33],
      ["FLOATS, RAFT, VESTS REMOVED", 2084.51, 3507.26]
  ];
  
  // values for AC N902AH
  /////////////////////////////////////////////////////////// 
  var N902AH = [
      ["Select a Configuration", "Select Config", "Select Config"],
      ["6 PAX STANDARD SEATS OFFSHORE", 2205.61, 3485.69],
      ["DUAL CONTROLS INSTALLED", 2207.81, 3483.76],
      ["VIP SEATS INSTALLED", 2212.11, 3483.75],
      ["VIP SEATS, DUAL CONTROLS INSTALLED", 2214.31, 3481.83],
      ["ONE LITTER KIT INSTALLED", 2213.91, 3483.50],
      ["ONE LITTER, DUAL CONTROLS INSTALLED", 2216.11, 3481.58],
      ["6 PAX STANDARD SEATS, VESTS REMOVED", 2196.81, 3489.83],
      ["VIP SEATS INSTALLED, VEST REMOVED", 2203.31, 3487.87],
      ["ONE LITTER INSTALLED, VESTS REMOVED", 2207.31, 3487.02],
      ["TWO LITTER INSTALLED", 2222.21, 3481.32],
      ["TWO LITTER, DUAL CONTROLS INSTALLED", 2224.41, 3479.41],
      ["VIP SEATS, DUAL CONTROLS INSTALLED, VESTS REMOVED", 2205.51, 3485.93],
      ["ONE LITTER, DUAL CONTROLS INSTALLED, VESTS REMOVED", 2209.51, 3485.09],
      ["TWO LITTER, DUAL CONTROLS INSTALLED, VESTS REMOVED", 2220.01, 3482.33],
      ["FLOATS, RAFT, VESTS REMOVED", 2084.51, 3507.26]
  ];
  
  // values for AC N903AH
  /////////////////////////////////////////////////////////// 
  var N903AH = [
      ["Select a Configuration", "Select Config", "Select Config"],
      ["6 PAX STANDARD SEATS OFFSHORE", 2205.61, 3485.69],
      ["DUAL CONTROLS INSTALLED", 2207.81, 3483.76],
      ["VIP SEATS INSTALLED", 2212.11, 3483.75],
      ["VIP SEATS, DUAL CONTROLS INSTALLED", 2214.31, 3481.83],
      ["ONE LITTER KIT INSTALLED", 2213.91, 3483.50],
      ["ONE LITTER, DUAL CONTROLS INSTALLED", 2216.11, 3481.58],
      ["6 PAX STANDARD SEATS, VESTS REMOVED", 2196.81, 3489.83],
      ["VIP SEATS INSTALLED, VEST REMOVED", 2203.31, 3487.87],
      ["ONE LITTER INSTALLED, VESTS REMOVED", 2207.31, 3487.02],
      ["TWO LITTER INSTALLED", 2222.21, 3481.32],
      ["TWO LITTER, DUAL CONTROLS INSTALLED", 2224.41, 3479.41],
      ["VIP SEATS, DUAL CONTROLS INSTALLED, VESTS REMOVED", 2205.51, 3485.93],
      ["ONE LITTER, DUAL CONTROLS INSTALLED, VESTS REMOVED", 2209.51, 3485.09],
      ["TWO LITTER, DUAL CONTROLS INSTALLED, VESTS REMOVED", 2220.01, 3482.33],
      ["FLOATS, RAFT, VESTS REMOVED", 2084.51, 3507.26]
  ];
  
  // values for AC N904AH
  /////////////////////////////////////////////////////////// 
  var N904AH = [
      ["Select a Configuration", "Select Config", "Select Config"],
      ["6 PAX STANDARD SEATS OFFSHORE", 2205.61, 3485.69],
      ["DUAL CONTROLS INSTALLED", 2207.81, 3483.76],
      ["VIP SEATS INSTALLED", 2212.11, 3483.75],
      ["VIP SEATS, DUAL CONTROLS INSTALLED", 2214.31, 3481.83],
      ["ONE LITTER KIT INSTALLED", 2213.91, 3483.50],
      ["ONE LITTER, DUAL CONTROLS INSTALLED", 2216.11, 3481.58],
      ["6 PAX STANDARD SEATS, VESTS REMOVED", 2196.81, 3489.83],
      ["VIP SEATS INSTALLED, VEST REMOVED", 2203.31, 3487.87],
      ["ONE LITTER INSTALLED, VESTS REMOVED", 2207.31, 3487.02],
      ["TWO LITTER INSTALLED", 2222.21, 3481.32],
      ["TWO LITTER, DUAL CONTROLS INSTALLED", 2224.41, 3479.41],
      ["VIP SEATS, DUAL CONTROLS INSTALLED, VESTS REMOVED", 2205.51, 3485.93],
      ["ONE LITTER, DUAL CONTROLS INSTALLED, VESTS REMOVED", 2209.51, 3485.09],
      ["TWO LITTER, DUAL CONTROLS INSTALLED, VESTS REMOVED", 2220.01, 3482.33],
      ["FLOATS, RAFT, VESTS REMOVED", 2084.51, 3507.26]
  ];
  
  // values for AC N905AH
  /////////////////////////////////////////////////////////// 
  var N905AH = [
      ["Select a Configuration", "Select Config", "Select Config"],
      ["6 PAX STANDARD SEATS OFFSHORE", 2205.61, 3485.69],
      ["DUAL CONTROLS INSTALLED", 2207.81, 3483.76],
      ["VIP SEATS INSTALLED", 2212.11, 3483.75],
      ["VIP SEATS, DUAL CONTROLS INSTALLED", 2214.31, 3481.83],
      ["ONE LITTER KIT INSTALLED", 2213.91, 3483.50],
      ["ONE LITTER, DUAL CONTROLS INSTALLED", 2216.11, 3481.58],
      ["6 PAX STANDARD SEATS, VESTS REMOVED", 2196.81, 3489.83],
      ["VIP SEATS INSTALLED, VEST REMOVED", 2203.31, 3487.87],
      ["ONE LITTER INSTALLED, VESTS REMOVED", 2207.31, 3487.02],
      ["TWO LITTER INSTALLED", 2222.21, 3481.32],
      ["TWO LITTER, DUAL CONTROLS INSTALLED", 2224.41, 3479.41],
      ["VIP SEATS, DUAL CONTROLS INSTALLED, VESTS REMOVED", 2205.51, 3485.93],
      ["ONE LITTER, DUAL CONTROLS INSTALLED, VESTS REMOVED", 2209.51, 3485.09],
      ["TWO LITTER, DUAL CONTROLS INSTALLED, VESTS REMOVED", 2220.01, 3482.33],
      ["FLOATS, RAFT, VESTS REMOVED", 2084.51, 3507.26]
  ];
  
  // values for AC N907AH
  /////////////////////////////////////////////////////////// 
  var N907AH = [
      ["Select a Configuration", "Select Config", "Select Config"],
      ["6 PAX STANDARD SEATS OFFSHORE", 2205.61, 3485.69],
      ["DUAL CONTROLS INSTALLED", 2207.81, 3483.76],
      ["VIP SEATS INSTALLED", 2212.11, 3483.75],
      ["VIP SEATS, DUAL CONTROLS INSTALLED", 2214.31, 3481.83],
      ["ONE LITTER KIT INSTALLED", 2213.91, 3483.50],
      ["ONE LITTER, DUAL CONTROLS INSTALLED", 2216.11, 3481.58],
      ["6 PAX STANDARD SEATS, VESTS REMOVED", 2196.81, 3489.83],
      ["VIP SEATS INSTALLED, VEST REMOVED", 2203.31, 3487.87],
      ["ONE LITTER INSTALLED, VESTS REMOVED", 2207.31, 3487.02],
      ["TWO LITTER INSTALLED", 2222.21, 3481.32],
      ["TWO LITTER, DUAL CONTROLS INSTALLED", 2224.41, 3479.41],
      ["VIP SEATS, DUAL CONTROLS INSTALLED, VESTS REMOVED", 2205.51, 3485.93],
      ["ONE LITTER, DUAL CONTROLS INSTALLED, VESTS REMOVED", 2209.51, 3485.09],
      ["TWO LITTER, DUAL CONTROLS INSTALLED, VESTS REMOVED", 2220.01, 3482.33],
      ["FLOATS, RAFT, VESTS REMOVED", 2084.51, 3507.26]
  ];
  
  
  // set form values to selected aircraft option  
  ///////////////////////////////////////////////////////////
  function showAircraft(idx) {
      var aircraftWB = [aircraft[idx][0]]
      alert(aircraftWB);
      $("#configWBList").html('');
      list(aircraftWB);
  }
  
  function list(arrary) {
      alert(arrary);
  
      // populate selected aircraft w&amp;b select
      ///////////////////////////////////////////////////////////
      for (i = 0; i &lt; arrary.length; i++) {
          var select = document.getElementById("configWBList");
          select.options[select.options.length] = new Option(arrary[i][0], arrary[i][1]);
      }
  
      // reset the selected aircraft configuration to standard
      ///////////////////////////////////////////////////////////
      $("#configWBList").val($("#configWBList option:first").val());
      $("#configWBList").selectmenu('refresh', true);
  
  }
  
  
  // initialise form
  // ****************************************************
  function initForm() {
      // populate aircraft select
      ///////////////////////////////////////////////////////////
      for (i = 0; i &lt; aircraft.length; i++) {
          var select = document.getElementById("aircraftList");
          select.options[select.options.length] = new Option(aircraft[i][0], aircraft[i][1]);
      }
  }
  
  initForm();
  </code></pre>
  
  <p><a href="https://jsfiddle.net/g3h9p2ur/" rel="nofollow">https://jsfiddle.net/g3h9p2ur/</a></p>