logo

Confirming a user's action


If you have links whose action is irreversible and you want to make the user confirm what they are doing then you could use the JavaScript onclick event.

The HTML to invoke this is:

<a href="../ViewName/DocID?DeleteDocument" onclick="return confirm('Are you sure you want to delete this document?');">Delete Document...</a>


Image

The onClick event will return either of two values depending on whether the user clicks 'Ok' or 'Cancel':

true - the link should be opened;
false - do not be opened;

Feedback

Hear that? Silence! Be the first to talk. Use the form below...

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:



Navigate other articles in the category "Quick Tips"

« Previous Article Next Article »
Quick, easy, foolproof field level help   Creating a dynamic, re-usable message form

About This Article

Author: Jake Howlett
Category: Quick Tips
Keywords: onclick; return; confirm; delete;

Options

Feedback
Print Friendly

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »