This blog site is not meant to be any information that is distributed to the general public. It is to serve as shared documentation between the DNSTC developers; however, if you find something useful and would like to use it, go right ahead.

Saturday, February 19, 2011

Verification of Delete

When creating a web application, you are most often going to have an option to delete a record from a database. In the past, this used to be done by sending the user to another page and ask for a verification of delete; however, the following javascript code can be used to verify deletion before the actual deletion actually takes place.

Add the following to the section of the page:
<script language="javascript" type="text/javascript">

function verifyDelete(page) {
if (confirm("Are you sure you want to delete this report?")) {
} else {
return false;

To call the function within the page itself, add the following to a link, button, or image:
<a href="javascript:verifyDelete('page_that_does_the_delete.php?key=#')">

Now, when the visitor clicks on the delete, a pop-up windows comes up and prompts asking if they are sure they want to delete the information. If they click on Cancel, then it just closes the pop-up and nothing happens. If they click on OK, then the delete program is called and the record is deleted.

No comments:

Post a Comment