HTML-如何使用 sweetalert 提交表单
HTML-How to submit a form with sweetalert
有人知道如何使用 sweetalert 在 html 中提交表单吗?
我有这个复选框,我希望 onchange 使用 2 个按钮“引导”我到 sweetalert js。一种是“否”,另一种是“是”。 “是”按钮现在应该是新的“onchange”,使用“否”按钮应该取消提交。
<form method='post' action='....'>
<input type="checkbox" name="checkbox_admin" onchange="submit();" checked>
</form>
希望你明白我的意思。 :D
这是我通常的做法
$(document).ready(function() {
$('[data-click="swal-danger"]').click(function(e) {
e.preventDefault();
var form = $(this).parents('form');
swal({
title: "Are You Sure?",
text: "Are You Sure You Want To Delete.",
icon: "error",
buttons: true,
dangerMode: true,
})
.then((willDelete) => {
if (willDelete) {
swal(form.submit(), {
icon: "success",
});
} else {
}
});
});
});
在通过 swal/Sweetalert
提交表单时使用它
swal(form.submit()
然后创建一个表单提交按钮,但没有下面的提交类型
<form method='post' action='....'>
<button class="btn btn-danger" data-click="swal-danger">DELETE USER</button>
</form>
确保你的按钮上有这个 data-click="swal-danger"
有人知道如何使用 sweetalert 在 html 中提交表单吗?
我有这个复选框,我希望 onchange 使用 2 个按钮“引导”我到 sweetalert js。一种是“否”,另一种是“是”。 “是”按钮现在应该是新的“onchange”,使用“否”按钮应该取消提交。
<form method='post' action='....'>
<input type="checkbox" name="checkbox_admin" onchange="submit();" checked>
</form>
希望你明白我的意思。 :D
这是我通常的做法
$(document).ready(function() {
$('[data-click="swal-danger"]').click(function(e) {
e.preventDefault();
var form = $(this).parents('form');
swal({
title: "Are You Sure?",
text: "Are You Sure You Want To Delete.",
icon: "error",
buttons: true,
dangerMode: true,
})
.then((willDelete) => {
if (willDelete) {
swal(form.submit(), {
icon: "success",
});
} else {
}
});
});
});
在通过 swal/Sweetalert
提交表单时使用它swal(form.submit()
然后创建一个表单提交按钮,但没有下面的提交类型
<form method='post' action='....'>
<button class="btn btn-danger" data-click="swal-danger">DELETE USER</button>
</form>
确保你的按钮上有这个 data-click="swal-danger"