title: Prepopulate a multiple select box from php using chosen Jquery
body: <p>I am using this script for my dropdowns
  <a href="http://harvesthq.github.io/chosen/" rel="nofollow">http://harvesthq.github.io/chosen/</a></p>
  
  <p>This is my select option which works great when starting with a blank field.</p>
  
  <pre><code>&lt;form&gt;
      &lt;select class="chosen-select" multiple="multiple" id="fm-site[]" name="fm-site[]" style="width:250px" value="&lt;?php echo $user_site;?&gt;"&gt;
                      &lt;option value="Pokerstars" &lt;?php if(in_array("Pokerstars",$site_array)){echo 'selected';}?&gt;&gt;Pokerstars&lt;/option&gt;
                      &lt;option value="Full Tilt Poker" &lt;?php if(in_array("Full Tilt Poker",$site_array)){echo 'selected';}?&gt;&gt;Full Tilt Poker&lt;/option&gt;
                      &lt;option value="Party Poker" &lt;?php if(in_array("Party Poker",$site_array)){echo 'selected';}?&gt;&gt;Party Poker&lt;/option&gt;
                      &lt;option value="Ipoker" &lt;?php if(in_array("Ipoker",$site_array)){echo 'selected';}?&gt;&gt;Ipoker Network&lt;/option&gt;
                      &lt;option value="Merge" &lt;?php if(in_array("Merge",$site_array)){echo 'selected';}?&gt;&gt;Merge&lt;/option&gt;
                      &lt;option value="Winners Poker Network" &lt;?php if(in_array("Winners Poker Network",$site_array)){echo 'selected';}?&gt;&gt;Winners Poker Network&lt;/option&gt;
                      &lt;option value="Microgaming" &lt;?php if(in_array("Microgaming",$site_array)){echo 'selected';}?&gt;&gt;Microgaming&lt;/option&gt;
                      &lt;option value="Ongame" &lt;?php if(in_array("Ongame",$site_array)){echo 'selected';}?&gt;&gt;Ongame&lt;/option&gt;
                      &lt;option value="Pacific" &lt;?php if(in_array("Pacific",$site_array)){echo 'selected';}?&gt;&gt;Pacific&lt;/option&gt;
                      &lt;option value="Boss" &lt;?php if(in_array("Boss",$site_array)){echo 'selected';}?&gt;&gt;Boss Poker&lt;/option&gt;
                      &lt;option value="PKR" &lt;?php if(in_array("PKR",$site_array)){echo 'selected';}?&gt;&gt;PKR Network&lt;/option&gt;
                      &lt;option value="Winning Poker" &lt;?php if(in_array("Winning Poker",$site_array)){echo 'selected';}?&gt;&gt;Winning Poker Network&lt;/option&gt;
                      &lt;option value="Revolution/Cake" &lt;?php if(in_array("Revolution/Cake",$site_array)){echo 'selected';}?&gt;&gt;Revolution/Cake&lt;/option&gt;
                      &lt;option value="Winimax" &lt;?php if(in_array("Winimax",$site_array)){echo 'selected';}?&gt;&gt;Winimax&lt;/option&gt;
                  &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>To allow users to edit it i pre-populate the current info from the database, this is working fine on all the normal input fields but cant get this working for the multiple select.</p>
  
  <p>I have all the values in an array like this:</p>
  
  <pre><code>$site_array = ("Pokerstars","Full Tilt Poker", "Party Poker", "Ipoker");
  </code></pre>
  
  <p>But when the form is printed out it only does the selected on the first one but in my debugger i can clearly see the array has Full Tilt Poker etc so i am not sure why it wont work. I also tried selected="selected" but i have a feeling that the chosen script is overwriting this because looking at the html the way the chosen Jquery works to add the selected is like this:</p>
  
  <pre><code>&lt;div id="fm_site___chosen" title="" style="width: 250px;" class="chosen-container chosen-container-multi"&gt;
      &lt;ul class="chosen-choices"&gt;
          &lt;li class="search-choice"&gt;
              &lt;span&gt;Pokerstars&lt;/span&gt;
              &lt;a data-option-array-index="0" class="search-choice-close"&gt;&lt;/a&gt;
          &lt;/li&gt;
          &lt;li class="search-choice"&gt;
               &lt;span&gt;Full Tilt Poker&lt;/span&gt;
               &lt;a data-option-array-index="1" class="search-choice-close"&gt;&lt;/a&gt;
         &lt;/li&gt;
         &lt;li class="search-field"&gt;
             &lt;input value="Select Some Options" class="" autocomplete="off" style="width: 25px;" type="text"&gt;
         &lt;/li&gt;
     &lt;/ul&gt;
  
     &lt;div class="chosen-drop"&gt;
     &lt;ul class="chosen-results"&gt;
         &lt;li data-option-array-index="0" style="" class="result-selected"&gt;
             Pokerstars
         &lt;/li&gt;
         &lt;li data-option-array-index="1" style="" class=""&gt;
             Full Tilt Poker
         &lt;/li&gt;
         &lt;li data-option-array-index="2" style="" class="active-result"&gt;
             Party Poker
         &lt;/li&gt;
         &lt;li data-option-array-index="3" style="" class="active-result"&gt;
             Ipoker Network
         &lt;/li&gt;
         &lt;li data-option-array-index="4" style="" class="active-result"&gt;
             Merge
         &lt;/li&gt;
         &lt;li data-option-array-index="5" style="" class="active-result"&gt;
             Winners Poker Network
         &lt;/li&gt;
         &lt;li data-option-array-index="6" style="" class="active-result"&gt;
             Microgaming
         &lt;/li&gt;
     &lt;/ul&gt;
     &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And i notice when a value gets added in this format that it doesnt update the selected value inside the option value and if you manually add it then it sometimes overwrites it. So i wonder is there a way via chosen jquery to pass it which ones should be pre-selected or maybe there is another similar jquery someone can recommend that does this, i have red the documentation but i havent seen anything specific to this issue but surely its possible?</p>