JavaScript Confirm before deletion with PHP/MYSQL [closed]

一个人想着一个人 提交于 2020-01-11 19:58:48

问题


I have tried a number of examples here but I can get my code to actually show a popup window before deletion. The code I use can be found here:


回答1:


  <script type="text/javascript">
      function ConfirmDelete()
      {
            if (confirm("Delete Account?"))
                 location.href='linktoaccountdeletion';
      }
  </script>


  echo '<input type="button" onclick="ConfirmDelete()" value="DELETE ACCOUNT">';



回答2:


You just need to use the onclick method for your link or button:

<a href="DELETE_PAGE" onClick="return confirm('Delete This account?')">Delete Account</a>



回答3:


try this

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

</form>



回答4:


Just say

onclick="return confirm('Are you sure you want to delete?')"
         ^^^^^^ --> this is very important step...



回答5:


javascript confirmation

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();
            }
        }

button for delete

<input type="button" onclick="doConfirm();"/>



回答6:


if u use on-click the data will be deleted but to view result u have to refresh the page manually instead use onSubmit="return confirm('are you sure?')"

think it helps !



来源:https://stackoverflow.com/questions/16121538/javascript-confirm-before-deletion-with-php-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!