【问题标题】:Can we submit a jsp form twice?我们可以提交两次jsp表单吗?
【发布时间】:2016-01-31 12:51:03
【问题描述】:

我有一个提交按钮,单击该按钮可以正常提交表单。 我有另一个元素,一个单击复选框,我需要提交表单。 是否可以? 如果是,如何?

【问题讨论】:

    标签: javascript html css forms jsp


    【解决方案1】:

    Javascript

    var checkbox = document.yourForm.yourCheckbox; // getting yourCheckbox
    checkbox.onclick = function() {                // a function that is executed when the checkbox is clicked
        if (checkbox.checked == true) {            // if checkbox is checked:
            document.yourForm.submit();            // submit the form
        }
    };
    

    HTML

    <form name="yourForm">
        <input type='checkbox' name='yourCheckbox'>
    </form>
    

    http://www.w3schools.com/jsref/met_form_submit.asp

    【讨论】:

    • 感谢您的帮助!! :)
    【解决方案2】:

    您可以执行以下操作

    <input type='checkbox' onclick='handleClick(this);'>Checkbox
    
    function handleClick(cb) {
    if(cb.checked)
    {
        document.getElementById("myForm").submit();
    }
    
    }
    

    希望对你有所帮助。

    【讨论】:

    • 感谢您的信息。您能否确认同一表单的单独提交按钮提交表单是否没有问题?
    • 是的,没有问题
    猜你喜欢
    • 1970-01-01
    • 2016-03-26
    • 1970-01-01
    • 2011-06-17
    • 1970-01-01
    • 2018-06-28
    • 2011-03-19
    • 1970-01-01
    相关资源
    最近更新 更多