Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Selected value from Multi-Value Select Boxes by jquery-select2?

I am using Select2 Jquery to bind my dropdown which is used for multiple selection . I am using select2 jquery.

It's working fine, I can bind my dropdown but I need to get the selected value from my multi-value selector. I am looking for method to get value which is supported by select2 Jquery. it might be having a function get selected value.
my drop down binding code

$(".leaderMultiSelctdropdown").select2( {     maximumSelectionSize: 4 }); 
like image 368
Kaps Hasija Avatar asked Oct 15 '12 04:10

Kaps Hasija


1 Answers

alert("Selected value is: "+$(".leaderMultiSelctdropdown").select2("val")); 

alternatively, if you used a regular selectbox as base, you should be able to use the normal jquery call, too:

alert("Selected value is: "+$(".leaderMultiSelctdropdown").val()); 

both return an array of the selected keys.

like image 86
Manuel Schweigert Avatar answered Sep 22 '22 11:09

Manuel Schweigert