Cybercrux

Everything is achievable through technology

Multi Select

 

Sample multi select droupdown

Demo

Html

<select multiple>
<option value="0">Potato</option>
<option value="1">Carrot</option>
<option value="2">Apple</option>
<option value="3">Raisins</option>
<option value="4">Peanut</option>
</select>

Jquery

$('select').on('change', function () {
// Get Multi select Value
console.log($(this).val().join(","));
// Get Multiselect Text
var foo = [];
$($(this) + ':selected').each(function (i, selected) {
foo[i] = $(selected).text();
});
console.log(foo.join(","));
});

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s