title: how to access multiple select array data in javascript
body: <p>I have a multiple select box and I want to access the selected data in javascript.
  Here is the code:</p>
  
  <pre><code>&lt;form onsubmit="return false;" id="multisel"&gt;
    &lt;select name="a[]" id="a" multiple style="width:350px;" tabindex="4"&gt;
      &lt;option value="Pedro"&gt;1&lt;/option&gt;
      &lt;option value="Alexis"&gt;2&lt;/option&gt;
      &lt;option value="Messi"&gt;3&lt;/option&gt;
      &lt;option value="Villa"&gt;4&lt;/option&gt;
      &lt;option value="Andres"&gt;5&lt;/option&gt;
      &lt;option value="Sergio"&gt;6&lt;/option&gt;
      &lt;option value="Xavi"&gt;7&lt;/option&gt;
    &lt;/select&gt;
  
    &lt;button id="btn1" onclick="ajaxmultiselect()" type="submit" class="btn btn-primary"&gt;Save changes&lt;/button&gt;
  
    &lt;p id="status"&gt;&lt;/p&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here is the code I have tried so far :</p>
  
  <pre><code>&lt;script&gt;    
  function ajaxmultiselect(){
    var input  = [];
    input = document.getElementById("a").value;
    var status = _("status");
    if(input == ""){
      status.innerHTML = "Fill out all of the form data";
    }else {
      status.innerHTML = input;
    }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>When I run the code it only gives the first value.
  I tried to access the values in php and it works fine, it passes the value as an array in php. Why isn't it doing the same with javascript?</p>
  
  <p>I also tried to run a loop for the length of the value but that calculates the length of the first selection only.
  I want to display all the values that will be selected.</p>
  
  <p>Any help will be appreciated.</p>