<div class="form-group"> <select id="multiselect1" class="form-control" id="bldg_type" multiple="multiple">{% for type in buildings %} <option value="{{type.bldg_type}}">{{type.bldg_type}}</option>{% endfor %} </select> </div>
Add the multiselect identifier to the select control.
Declare the variable globally in your javascript, as shown below:
var selected = [];
Initialize it as below [from the response link you provided]
$('#multiselect1').multiselect({ selectAllValue: 'multiselect-all', onChange: function(element, checked) { var brands = $('#multiselect1 option:selected'); $(brands).each(function(index, brand){ selected.push([$(this).val()]); }); } });
Send it through your ajax.
$.ajax({ url: "cnt_bldg/", type: "GET", dataType: "JSON", data: { 'brgy_id': brgy_id, 'bldg_type': selected
Note. . When manipulating the resulting values, take it as a list of strings in the server method.
source share