button點擊按鈕觸發提交from表單數據


1.html代碼

<form method="post" action="/xxx/" id="filter_all" >
    {% csrf_token %}
    <select name="filter_platform" id="filter_platform" style="height: 30px;border: 0;width: 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;width: 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;width: 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表單提交
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM