title: Html datalist values from array in javascript
body: <p>I have a simple program which has to take the values from the text file on server and then populate on the datalist as the selection in the input text field.</p>
  
  <p>For this purpose the first step i want to take is that i want to know that how the array of javascript can be used as a datalist options dynamically.</p>
  
  <p>My Code is :</p>
  
  <pre><code>&lt;html&gt;  
  &lt;script&gt;
  
  var mycars = new Array();
  mycars[0]='Herr';
  mycars[1]='Frau';
  
  &lt;/script&gt;
  
  &lt;input name="anrede" list="anrede" /&gt;
  &lt;datalist id="anrede"&gt;
   &lt;option value= mycars[0]&gt;&lt;/option&gt;
   &lt;option value="Frau"&gt;&lt;/option&gt; 
  &lt;/datalist&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I want to populate the input text field containing the datalist as suggestion from the array. Also here I havenot take into account the array values. Actually i need not two datalist options but dxnamic depending on the array length</p>