fetch values of select elements as query string array
<p>i am fetching all the values from select element, which will not have <code>selected</code> attribute using this piece of jquery code.</p>

<pre><code>$('#purchaseEditUpdateItemBtn').on('click', function(){
    var selected = [];
    $('#box2View option').each(function(index, element){ 
        selected[index] = $(element).val(); 
    });
    return false;
});
</code></pre>

<p>here is my select box.</p>

<pre><code> &lt;select id="box2View" multiple="multiple" class="multiple"&gt;
     &lt;option value="1"&gt;ITEM001&lt;/option&gt;
     &lt;option value="2"&gt;ITEM002&lt;/option&gt;
     &lt;option value="3"&gt;ITEM003&lt;/option&gt;
     &lt;option value="4"&gt;ITEM004&lt;/option&gt;
 &lt;/select&gt;
</code></pre>

<p>this will create a javascript array named <code>selected</code> and hold the values as an array.i want to fetch all the values from option and emulate the query like this.</p>

<pre><code>estimate_id[]=1&amp;estimate_id[]=2&amp;estimate_id[]=3&amp;estimate_id[]=4
</code></pre>

<p>so that it is received by server side as an array.</p>

<p>P.S: please note that, i want to fetch all the elements from select elements without user selecting any, so for the reason, selected attribute is not used. i tried using <code>serialize()</code> which didn't work because <code>serialize()</code> requires the elements to be selected, which cannot be true in my case.</p>

<p>thank you</p>
