[英]Request for confirmation before submitting the form
I am beginner web developer.我是初学者 web 开发人员。 I have this code:
我有这个代码:
<a href="javascript:void(0);" onclick="$(this).find('form').submit();"><i class="removeItem far fa-trash-alt"></i><form action="http://domain.test/_admin/products/destroy" method="post"><input type="hidden" name="_method" value="DELETE"><input type="hidden" name="_token" value="O94UFcB8Woh5BmH7zGZID1lR3Pz4J1wAIrcoJGmw"><input type="hidden" name="id" value="2"></form></a>
It's work fine.它工作正常。 I have this in my DataTables.js
我的 DataTables.js 中有这个
I would like to add to my code the question "Are you sure you want to delete this. Record?"我想在我的代码中添加问题“您确定要删除这个。记录吗?” yes / no
是/否
How can this be done in my code?如何在我的代码中做到这一点?
Hello maybe you can add an function with a if and a confirm().您好,也许您可以使用 if 和 confirm() 添加 function。
If the user click on OK delet else stop the launch.如果用户单击确定删除,则停止启动。
function confirmMessage() {
if ( confirm( "Are you sure to want delet this ? " ) ) {
// Code for submit if the user click on "OK"
// maybe
// document.forms["yourForm"].submit();
} else {
// Code if the user click on "cancel"
}
And you can launch the function in your on click i think.我认为您可以在单击时启动 function。
Maybe add à name for your form for can sélect it in the function.也许为您的表单添加一个名称,以便可以在 function 中选择它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.