How to put an alert box for delete button

Posted on 2006-04-03
Last Modified: 2010-04-17
I have an edit link in a form which calls a server side page to delete a specific record. What I need is an alert box before calling the server side page, if the user enter yes it should call the page and pass the "ID" and if the user clicks on No do nothing. Can anyoe please help in how to implement this

Any help will be greatly appreciated
Question by:royalcyber
    LVL 3

    Expert Comment

    server technology and scripting language?
    LVL 3

    Expert Comment

    <a href="#" onclick="customConfirm('remove.asp?ID=<%
    =server.URLEncode(RS("ID"))%>');return false">Remove</a>

    Author Comment

    I am using JSP and javascript.

    here is my code

    <td><a href="chapter_admin?action=delete_events&eid2=<%= next_event.getEvents_ID() %>">remove</td>

    Couple of quick questions
    So should I make a javascipt function or JSP method named customConfirm and why do you have return false at the end of the tag.
    Also if you would have any example I can look over, it will be greatly helpful

    LVL 3

    Accepted Solution

    <a href="chapter_admin?action=delete_events&eid2=<%= next_event.getEvents_ID() %>" onclick="javascript:return confirm('Are you sure you want to delete this record ?')"><BR>
    Delete this record</a>

    you use the return false to (do nothing)...but the code I just pasted is better.

    You can use confirm for BUTTONS (on forms) and add IF statemsnts.

    If you wanted to delete multiple records, then yes, you'd have to create a jsp page that takes in the "GET" or "POST" variables and deletes the records.  You would confirm() on the submit button.

    Author Comment

    Thanks it works
    LVL 3

    Expert Comment


    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    sameEnds challenge 25 57
    Order table with macro 3 66
    hasOne  challenge 59 64
    Program to display an alert on Windows Toolbar 2 32
    Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
    A short article about a problem I had getting the GPS LocationListener working.
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    734 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

    18 Experts available now in Live!

    Get 1:1 Help Now