change maximumSelectionLength value

29 views
Skip to first unread message

jorge....@gmail.com

unread,
Dec 12, 2015, 4:45:48 PM12/12/15
to select2
Hi.
I want to set diferent values for maximumSelectionLength according to a selected option.

Branches (select2):
<select id="branches" name="branches" multiple="multiple>
<options>
</select>

<script type="text/javascript">
$("#wgt-branches").select2({});
</script>


I want to limit the number of branches you can select according to the option selected here:
<select onchange="newLength(this)">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
</select>

this is what I tried and it didn't work:
<script>
function newLength(value){
var seleccion=$(value).val();
$("#wgt-branches").select2({maximumSelectionLength:seleccion});
}
</script>

thanks for your help.

B/R.

Reply all
Reply to author
Forward
0 new messages