i am fetching all the values from select element, which will not have selected attribute using this piece of jquery code.
$('#purchaseEditUpdateItemBtn').on('click', function(){
var selected = [];
$('#box2View option').each(function(index, element){
selected[index] = $(element).val();
});
return false;
});
here is my select box.
<select id="box2View" multiple="multiple" class="multiple">
<option value="1">ITEM001</option>
<option value="2">ITEM002</option>
<option value="3">ITEM003</option>
<option value="4">ITEM004</option>
</select>
this will create a javascript array named selected and hold the values as an array.i want to fetch all the values from option and emulate the query like this.
estimate_id[]=1&estimate_id[]=2&estimate_id[]=3&estimate_id[]=4
so that it is received by server side as an array.
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 serialize() which didn't work because serialize() requires the elements to be selected, which cannot be true in my case.
thank you