title: Javascript auto select multiple if value is array
body: <p>I have a javascript script that allows me to select data from drop down menus, how would I modify my script to be able to select from an array instead of just a single value?</p>
  
  <pre><code>&lt;script type='text/javascript'&gt;
  $(window).load(function(){
      $("select[value]").each(function() {
          $(this).val(this.getAttribute("value"));
      });
  }); 
  &lt;/script&gt;
  </code></pre>
  
  <p>In the HTML code normally I would just put the value as the data from the database, and it would auto select it. But with a multi select, I have it in the database as</p>
  
  <pre><code>option1,option2,option3
  </code></pre>
  
  <p>And then I turn it into an array</p>
  
  <p></p>
  
  <pre><code>Array
  (
      [0] =&gt; option1
      [1] =&gt; option2
      [2] =&gt; option3
  )
  </code></pre>
  
  <p>So how would I tell my script to select each and every value in the array?</p>