title: I want to add multiple selection in Javascript
body: <p>When I try to select two options it gives me the first option two times.</p>
  
  <p>Here is the code :</p>
  
  <pre><code>&lt;head&gt;
    &lt;script type="text/javascript"&gt;
      function choices() {
        var y = document.getElementById("s");
        var x = document.getElementById("output");
        var choice = y.value;
        for (i = 1; i &lt;= 3; i++) {
          var current = y[i];
          if (current.selected == true) {
            x.innerHTML += "the language is, " + choice + "&lt;br&gt;";
          }
        }
      }
  
    &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;form action=""&gt;
      &lt;fieldset&gt;
        &lt;select id="s" multiple="multiple" size="4"&gt;
          &lt;option&gt;--Choose language--&lt;/option&gt;
          &lt;option value="HTML"&gt;HTML&lt;/option&gt;
          &lt;option value="JAVA"&gt;JAVA&lt;/option&gt;
          &lt;option value="PHP"&gt;PHP&lt;/option&gt;
        &lt;/select&gt;
        &lt;input type="button" value="show" onclick="choices()"&gt;
      &lt;/fieldset&gt;
    &lt;/form&gt;
    &lt;div id="output"&gt;&lt;/div&gt;
  
  &lt;/body&gt;
  </code></pre>