We help IT Professionals succeed at work.

How to put an alert box for delete button

royalcyber asked
Medium Priority
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
Watch Question

server technology and scripting language?

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


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

<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.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


Thanks it works

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.