gpt4 book ai didi

javascript - 禁用按钮并发送 POST 请求

转载 作者:行者123 更新时间:2023-12-03 12:06:42 25 4
gpt4 key购买 nike

我有一个运行缓慢的表单,我想在单击后禁用其提交按钮。我做了这样的事情:http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_pushbutton_disabled2 。但现在我的按钮无法发送 POST 请求。做什么?

代码:

    <form id="command" action="/smsc/userRole/sms/sendMassSMS" method="POST">

<a href="/smsc/userRole/sms/mass" class="btn btn-danger btn-sm">Нет,
отмена</a>&#160;&#160;
<input type="submit" class="btn btn-success btn-sm"
value="Да, отправляем" onclick="myFunction()" id="send">
</form>
<script>
function myFunction() {
document.getElementById("send").disabled = true;
}
</script>

最佳答案

将 myFunction() 代码替换为以下代码

function myFunction() {
document.getElementById("send").disabled = true;
document.getElementById("command").submit();
}

关于javascript - 禁用按钮并发送 POST 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25154464/

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