gpt4 book ai didi

javascript - 我们可以提交一个jsp表单两次吗?

转载 作者:行者123 更新时间:2023-11-28 02:59:56 25 4
gpt4 key购买 nike

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

最佳答案

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

关于javascript - 我们可以提交一个jsp表单两次吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35114040/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com