Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery getting selected options issue
    text
    copied!<p>I have 2 multi-select boxes that transfer to each other. The transfer both ways goes fine. I also call an ajax fn to submit the selected options to a database. The call from left to right works fine because I am just getting all the options, not just selected ones.</p> <pre><code>var domelts = $('#imfavs option'); // next translate that into an array of just the values var buddylist = $.map(domelts, function(elt, i) { return $(elt).val();}); </code></pre> <p>Now, when I try to go from right to left with just the selected options, it's always returning an empty array.</p> <p>I tried 2 ways</p> <pre><code>var domelts = $('#imfavs :selected'); var removelist = $.map(domelts, function(elt, i) { return $(elt).val();}); $('#imfavs :selected').each(function (x) { removelist[x] = $(this).val(); }); </code></pre> <p>for the 2nd one, removelist is var'd before.</p> <p>My HTML</p> <pre><code> &lt;form method="post" name="frmFavs" id="frmFavs"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;strong&gt;Current Friends&lt;/strong&gt;&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&lt;strong&gt;SLS Chat Friends&lt;/strong&gt;&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;select name="userfavs" multiple="multiple" size="25" id="userfavs"&gt; &lt;cfoutput query="userfavs"&gt;&lt;option value="#encrypt(userfavs.user2id,application.key,'DES','Hex')#"&gt;#userfavs.user2#&lt;/option&gt;&lt;/cfoutput&gt; &lt;/select&gt; &lt;/td&gt; &lt;td&gt; &lt;button type="button" style="height:100px;" id="add"&gt;&amp;gt;&lt;/button&gt;&lt;br /&gt; &lt;button type="button" style="height:100px;" id="remove"&gt;&amp;lt;&lt;/button&gt; &lt;/td&gt; &lt;td&gt; &lt;select name="imfavs" multiple="multiple" size="25" id="imfavs"&gt;&lt;/select&gt; &lt;/td&gt; &lt;td valign="middle"&gt;&lt;div id="info"&gt;&lt;/div&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p>Any help appreciated.</p> <p>Thanks.</p>
 

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