JavaScript Confirm before deletion with PHP/MYSQL [closed]

这一生的挚爱 提交于 2019-12-03 00:43:06
  <script type="text/javascript">
      function ConfirmDelete()
      {
            if (confirm("Delete Account?"))
                 location.href='linktoaccountdeletion';
      }
  </script>


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

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>

try this

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

</form>

Just say

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

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();"/>

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 !

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