1.html代码
<form method="post" action="/xxx/" id="filter_all" > {% csrf_token %} <select name="filter_platform" id="filter_platform" style="height: 30px;border: 0; 250px;border-radius: 7px;background-color: #e2e2f5;"> <option value="" style="display: none;" disabled selected>平台:{{ filter_platform }}</option> {% for server_host_type in server_host_type_list %} <option value="{{ server_host_type }}">{{ server_host_type }}</option> {% endfor %} </select> <select name="filter_accoount" id="filter_accoount" style="height: 30px;border: 0; 250px;border-radius: 7px;background-color: #e2e2f5;"> <option value="" style="display: none;" disabled selected>账号:{{ filter_accoount }}</option> {% for account in accoount_list %} <option value="{{ account.platform }}_{{ account.account }}({{ account.name }})">{{ account.platform }}_{{ account.account }}({{ account.name }})</option> {% endfor %} </select> <select name="filter_project" id="filter_project" style="height: 30px;border: 0; 250px;border-radius: 7px;background-color: #e2e2f5;"> <option value="" style="display: none;" disabled selected>项目:{{ filter_project }}</option> {% for project in project_list %} <option value="{{ project.id }}">{{ project.name }}</option> {% endfor %} </select> <button class="layui-btn layui-btn-small" style="height: 30px;line-height:1.6em;" title="筛选" onclick="submitForm_filter_platform()"> <i class="layui-icon" style="line-height:32px;font-size: 14px;">筛选</i> </button> </form>
2.javascript代码
function submitForm_filter_platform(){ //获取form表单对象,提交选择项目 var form = document.getElementById("filter_all"); form.submit();//form表单提交 }