Reputation: 383
Simple question but I just can't find the answer. I'm using the 'a beautiful site' jquery multiSelect dropdown select plugin <link>. Everything seems to work using:
$(document).ready(function() {
$("#contact).multiSelect();
});
Then in the body:
<select id="contact" name="contact_list[]" multiple="multiple" size="5">
<option value=""></option>
<option value="Alekseev">Alekseev</option>
<option value="Bettis">Bettis</option>
<option value="Chlachula">Chlachula</option>
<option value="Kohfeld">Kohfeld</option>
<option value="Maher">Maher</option>
<option value="Muhs">Muhs</option>
</select>
The simple question is: how do I retrieve a JavaScript array of the selected values equivalent to the simple non-jquery:
var contactName = document.getElementById('contact').value;
Appreciate any help.
Upvotes: 0
Views: 420
Reputation: 73896
Try this:
var arr = $("#contact").val();
console.log(arr); // ["Bettis", "Chlachula"]
Upvotes: 1