繁体   English   中英

带有 HTML5 按钮元素的确认对话框

[英]Confirmation dialog with HTML5 button element

我有一个像这样的按钮元素:

<button name="command" type="submit" form="frmLandUnits" class="btn btn-danger" title="Delete" value="Delete:1:352404725228987" onclick="return confirm('Are you sure?');">
      <span class="glyphicon glyphicon-trash" aria-hidden="true">
    </span></button>

它是表单内表中数据输入网格的一部分。 每一行都有其他按钮,如更新,还有一个带有插入按钮的新行。 问题是单击“确定”时,未提交表单。 对此的谷歌搜索没有找到我能找到的任何东西。

 <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <form name="frmLandUnits" method="POST" action="https://httpbin.org/post"> <button name="command" type="submit" class="btn btn-danger" title="Delete" value="Delete:1:352404725228987" onclick="return confirm('Are you sure?');"> <span class="glyphicon glyphicon-trash" aria-hidden="true"> </span></button> </form>

该行为与带有input onclick不同。 这就是为什么在我看来这不是重复的。

只需从您的button删除form属性。

<button name="command" type="submit" class="btn btn-danger" title="Delete" value="Delete:1:352404725228987" onclick="return confirm('Are you sure?');">
      <span class="glyphicon glyphicon-trash" aria-hidden="true">
    </span></button>

结帐这个演示

<form id="frmLandUnits" method="GET" action="www.microsoft.com" onsubmit="return confirm('Do you really want to submit the form?');"  >

<button name="command" type="submit" form="frmLandUnits" class="btn btn-danger" 
title="Delete" value="Delete:1:352404725228987" >
  <span class="glyphicon glyphicon-trash" aria-hidden="true">
</span></button>
</form>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM