Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well actually your only need $.each to get all values, it will help you <a href="http://jsfiddle.net/NdQbw/5" rel="noreferrer">jsfiddle.net/NdQbw/5</a></p> <pre><code>&lt;div class="divright"&gt; &lt;select id="drp_Books_Ill_Illustrations" class="leaderMultiSelctdropdown Books_Illustrations" name="drp_Books_Ill_Illustrations" multiple=""&gt; &lt;option value=" "&gt;No illustrations&lt;/option&gt; &lt;option value="a" selected&gt;Illustrations&lt;/option&gt; &lt;option value="b"&gt;Maps&lt;/option&gt; &lt;option value="c" selected&gt;selectedPortraits&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;div class="divright"&gt; &lt;select id="drp_Books_Ill_Illustrations1" class=" Books_Illustrations" name="drp_Books_Ill_Illustrations" multiple=""&gt; &lt;option value=" "&gt;No illustrations&lt;/option&gt; &lt;option value="a"&gt;Illustrations&lt;/option&gt; &lt;option value="b"&gt;Maps&lt;/option&gt; &lt;option value="c"&gt;selectedPortraits&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;button class="getValue"&gt;Get Value&lt;/button&gt; &lt;button class="setValue"&gt; Set value &lt;/button&gt; &lt;div class="divright"&gt; &lt;select id="drp_Books_Ill_Illustrations2" class="leaderMultiSelctdropdown Books_Illustrations" name="drp_Books_Ill_Illustrations" multiple=""&gt; &lt;option value=" "&gt;No illustrations&lt;/option&gt; &lt;option value="a" selected&gt;Illustrations&lt;/option&gt; &lt;option value="b"&gt;Maps&lt;/option&gt; &lt;option value="c" selected&gt;selectedPortraits&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;div class="divright"&gt; &lt;select id="drp_Books_Ill_Illustrations3" class=" Books_Illustrations" name="drp_Books_Ill_Illustrations" multiple=""&gt; &lt;option value=" "&gt;No illustrations&lt;/option&gt; &lt;option value="a"&gt;Illustrations&lt;/option&gt; &lt;option value="b"&gt;Maps&lt;/option&gt; &lt;option value="c"&gt;selectedPortraits&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;button class="getValue1"&gt;Get Value&lt;/button&gt; &lt;button class="setValue1"&gt; Set value &lt;/button&gt; </code></pre> <p>The script:</p> <pre><code> var selectedValues = new Array(); selectedValues[0] = "a"; selectedValues[1] = "c"; $(".getValue").click(function() { alert($(".leaderMultiSelctdropdown").val()); }); $(".setValue").click(function() { $(".Books_Illustrations").val(selectedValues); }); $('#drp_Books_Ill_Illustrations2, #drp_Books_Ill_Illustrations3').select2(); $(".getValue1").click(function() { alert($(".leaderMultiSelctdropdown").val()); }); $(".setValue1").click(function() { //You need a id for set values $.each($(".Books_Illustrations"), function(){ $(this).select2('val', selectedValues); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload