【发布时间】:2021-04-20 19:45:47
【问题描述】:
我创建了一个具有演示登录功能的应用程序。演示登录将弹出一个甜蜜的警报,让用户知道他们所做的更改不会保存到数据库中。问题是在用户按下将关闭甜蜜警报的确定按钮后表单没有提交。按下确定按钮后提交表单的正确语法是什么?
下面是我的html:
<form method="post" id="submitForm" name="demoSubmitForm">
<div class="demo-button pt-3">
<button type="button" name="demoEmail" value="DemoEmail" class="au-btn au-btn--block au-btn--blue
m-b-20" onclick="ShowSweetAlert()">
Demo Application
</button>
</div>
</form>
下面是我的脚本:
function ShowSweetAlert() {
Swal.fire({
icon: 'warning',
title: 'You are logging in as a Demo User!',
text: 'Changes you make to the Application will not be saved once you log out.',
onClose: document.getElementById('submitForm').submit() /*document.demoSubmitForm.submit()*/
});
}
目前document.demoSubmitForm.submit() 和document.getElementById('submitForm').submit() 都无法提交表单。
【问题讨论】:
标签: javascript html sweetalert2