5

我在这里尝试了许多示例,但我可以让我的代码在删除之前实际显示一个弹出窗口。我使用的代码可以在这里找到:

echo "<td><button class='btn'><a href=\"deleteuserExecute2.php?login=" .$login. "\" onClick=\"return confirm(\'Delete this Account?\')\"; >DELETE ACCOUNT </a></button></td>";

http://jsfiddle.net/mpogoro/EGfcY/

4

6 回答 6

22

您只需要使用onclick链接或按钮的方法:

<a href="DELETE_PAGE" onClick="return confirm('Delete This account?')">Delete Account</a>
于 2013-04-20T14:46:50.610 回答
12
  <script type="text/javascript">
      function ConfirmDelete()
      {
            if (confirm("Delete Account?"))
                 location.href='linktoaccountdeletion';
      }
  </script>


  echo '<input type="button" onclick="ConfirmDelete()" value="DELETE ACCOUNT">';
于 2013-04-20T14:41:59.693 回答
4

试试这个

 <form action="url/to/delation_page" onSubmit="return confirm('are you sure?')">

</form>
于 2013-04-20T14:48:41.387 回答
3

说啊

onclick="return confirm('Are you sure you want to delete?')"
         ^^^^^^ --> this is very important step...
于 2013-04-20T14:50:14.970 回答
1

javascript确认

function doConfirm(id)
        {

            var ok = confirm("Are you sure to Delete?")
            if (ok)
            {

                if (window.XMLHttpRequest)
                {// code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlhttp = new XMLHttpRequest();
                }
                else
                {// code for IE6, IE5
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }

                xmlhttp.onreadystatechange = function()
                {
                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                    {
                         window.location = "create_dealer.php";  // self page
                    }
                }

                xmlhttp.open("GET", "delete_dealer.php?id=" + id);
                xmlhttp.send();
            }
        }

删除按钮

<input type="button" onclick="doConfirm();"/>
于 2014-07-10T10:46:43.597 回答
0

如果你使用点击数据将被删除,但要查看结果你必须手动刷新页面而不是使用 onSubmit="return confirm('are you sure?')"

觉得有帮助!

于 2013-11-29T11:51:08.573 回答