如果确认变量value
为真,有什么方法可以触发提交?我有一个两个单选按钮,上面有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>
答案 0 :(得分:3)
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"....