title: How to populate the options of a select element in javascript
body: <p>The code:</p>
  
  <pre><code>var newSelect=document.createElement('select');
  index=0;
  var optn = document.createElement("option");
  
  //langArray is an array that contains different items..the size
  //is not fixed for this array.
  
  for(element in langArray)
  {
     //Now i want to assign each item in langArray to each option tag
     //will it be sumthng like "optn.options[index]=new Option("Sports", "sportsvalue", true,  false);
     //optn.accept(langArray[0]);
     index++;
  }
  </code></pre>
  
  <p>I'm trying to get options populated by this way but its not coming all right as I don't know how to populate the options from an array in JS. Do I even have to use the loop or can I just assign the langArray to some property of select element and every thing will be up and running?</p>