After successfully moving items from one list box to another, the next step is to save the list of all items in the second list box along with their respective ids into the database. However, there seems to be an issue with retrieving the ids from the second list box. What would be the most effective way to extract all the items from the list box and transmit them to the controller? Here is the code:
Html:
<div class="control-group">
<div class="selector">
<select multiple="multiple" id="SelectLeft" ng-model="TaxId" ng-options="tax.TaxId as tax.TaxName for tax in Taxes"></select>
</div>
<input id="MoveRight" type="button" value=" >> " ng-click="MoveTaxes()" />
<input id="MoveLeft" type="button" value=" << " ng-click="MoveTaxes()" />
<div class="selector">
<select id="SelectRight" ng-model="SelectRight" multiple="multiple">
</select>
</div>
</div>
JS code is here:
$("#MoveRight,#MoveLeft").click(function (event) {
var id = $(event.target).attr("id");
var selectFrom = id == "MoveRight" ? "#SelectLeft" : "#SelectRight";
var moveTo = id == "MoveRight" ? "#SelectRight" : "#SelectLeft";
var selectedItems = $(selectFrom + " :selected").toArray();
$(moveTo).append(selectedItems);
selectedItems.remove;
});