I am using Bootstrap Multiselect, this is my setup in my HTML:
<div class="form-group">
<select class="form-control" id="bldg_type" multiple="multiple">{% for type in buildings %}
<option value="{{type.bldg_type}}">{{type.bldg_type}}</option>{% endfor %}
</select>
</div>
I wanted to use the selected values for my query, the snippet of my Ajax code:
$.ajax({
url: "cnt_bldg/",
type: "GET",
dataType: "JSON",
data: {
'brgy_id': brgy_id,
'bldg_type': $('#bldg_type option:selected').val()
},
...
The problem with $('#bldg_type option:selected').val()
is I can only get 1 value. For e.g. I check Market
and Police Station
in my select option, and looked it in my console http://127.0.0.1:8000/cnt_bldg/?brgy_id=All&bldg_type=Market".
It only gets the Market
.
How do I get all the values and use it for my query?
BTW, I'm using Django. I have read this answer already, but I don't know how to use the result in my AJAX code above.
have you tried simple
$('#bldg_type').val()
It works in my bootstrap-multiselect.