Reputation: 1060
I'm using chosen for my multiple select box, but I don't know how to get the selected items?
<select class="multiselect" multiple="" name="parlementId">
@foreach (Politicus p in politici)
{
<option value="@p.politicusID">@Html.DisplayName(p.Account.voornaam.ToString())</option>
}
</select>
$('.multiselect').chosen({ width: '500px', allow_single_deselect: true, max_selected_options: 5 });
$('.multiselect').on('change', function (evt, params) {
//this is where I need to know which options are selected
});
Upvotes: 0
Views: 2981
Reputation: 62498
you can get like this:
var values = $(".multiselect").chosen().val();
// this will give you values in an array
or:
var values = $(".multiselect").val();
Upvotes: 4