gpt4 book ai didi

javascript - 如何使用确认对话框触发提交?

转载 作者:行者123 更新时间:2023-11-28 18:25:47 27 4
gpt4 key购买 nike

如果 value 的确认变量为 true,有没有办法触发提交?我有一个两个单选按钮,上面有 onclick 事件,该事件将显示每个单选按钮的确认对话框。我只是想在用户选择确认对话框上的“确定”按钮时触发提交。

<script>

function showApprove()
{
value = confirm("Approve this document?");
if (value == true)
{

}
else
{
return false;
}
}

function showReject()
{
value = confirm("Reject this document?");
if (value == true)
{

}
else
{
return false;
}
}

</script>

<form class = "form-inline" method = "post" action = "{{ url('documents/pending') }}">

<input type="hidden" name = "id" value = "{{$list->id}}">

<div class = "radio">
<label><input type = "radio" onclick = "showApprove()" name = "status" value="1"> Approve</label>
</div>

<div class = "radio">
<label><input type = "radio" onclick = "showReject()" name = "status" value="0"> Reject</label>
</div>

</form>

最佳答案

function showApprove()
{
value = confirm("Approve this document?");
if (value == true)
{
document.getElementById("myForm").submit();
}
else
{
return false;
}
}

function showReject()
{
value = confirm("Reject this document?");
if (value == true)
{

document.getElementById("myForm").submit();

}
else
{
return false;
}
}
</script>


add id in form



<form id="myForm" class = "form-inline" method = "post"....

关于javascript - 如何使用确认对话框触发提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39189367/

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