我有html select2,它可以选择多个选项:
{% extends "base.html" %}
{% block title %}Index{% endblock %}
{% block head %}
<!-- some content here -->
{% endblock %}
{% block content %}
<!-- some content here -->
{% endblock %}
这个jquery:
但在PHP中,它只显示了1个选项。如何解决?
答案 0 :(得分:1)
将下拉列表名称更改为数组:
<select name="for" id="for" class="for" multiple="multiple" placeholder="For" style="width: 92%">
<select name="for[]" id="for" class="for" multiple="multiple" placeholder="For" style="width: 92%">
JS:
var selectedOpt = $('#for').val(); // it will return an array of selected options
// Now use the selectedOpt array in your ajax call