title: how to make a drop down list from 2d array and display the value in input?
body: <p>I want to display a drop down list whose entries are filled by the coder and the list is made using multidimensional array... and the value of the selected drop down should be displayed in input box.</p>
  
  <p>The following one was working only with the 1d array. </p>
  
  <p>Html code:</p>
  
  <pre><code>&lt;form id="myForm"&gt;
  &lt;select id="selectCity"&gt;
  &lt;option&gt;Choose a city&lt;/option&gt;
  &lt;/select&gt;
  &lt;/form&gt;
  &lt;input type="text" name="txtprice" id="txtprice" onClick="checkPrice()"&gt;
  </code></pre>
  
  <p>Javascript code:</p>
  
  <pre><code>var city = new Array()
  city[0][H: 1] = "Delhi";
  city[1][H: 2] = "Mumbai";
  city[2][H: 3] = "Bangalore";
  city[3][H: 4] = "Kolkata";
  city[4][H: 5] = "Chennai";
  city[5][H: 6] = "Hyderabad";
  city[6][H: 7] = "Ahemdabad";
  var dropdown = document.getElementById("selectCity");
  for (var i = 1; i &lt; city.length; ++i) {
  dropdown[dropdown.length] = new Option(city[i], city[i]);
  }
  var select = document.getElementById('myForm');
  var input = document.getElementById('txtprice');
  select.onchange = function () {
  input.value = select.value;
  }
  </code></pre>