Alert before delete

Posted on 2009-02-18
Last Modified: 2013-12-12
Hey guys, I have this code to delete some data from my db:

<a href="?acao=delete&id=<?php echo $row['id'] ?>">Delete</a>

How can I add a javascript alert that ask the user to confirm or cancel before delete the data?!
Question by:fackz
    LVL 36

    Expert Comment

    by:Loganathan Natarajan
    simple way,

    <a href="?acao=delete&id=<?php echo $row['id'] ?>" onclick="return confirm('Do you want to really delete?');">Delete</a>

    Open in new window

    LVL 19

    Expert Comment

    LVL 36

    Accepted Solution


    <script language="JavaScript">
    function confirmSubmit() {
    var agree=confirm("Are you sure you wish to continue?");
    if (agree)
         return true;
         return false;
    <a href="?acao=delete&id=<?php echo $row['id'] ?>" onclick="return confirmSubmit()" >Delete </a>

    Open in new window


    Author Closing Comment

    exactly what I need...thank you very much!

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now