Javascript code to prompt delete

This simple javascript code can be used to prompt user whether they want to proceed with an action or not. Usually be used when user click on delete or remove button/link.

The javascript code

1
2
3
4
5
6
7
8
9
10
11
12
<script LANGUAGE="JavaScript">
<!--
function confirmSubmit()
{
var agree=confirm("Are you sure you want to DELETE this record?");
if (agree)
	return true ;
else
	return false ;
}
// -->
</script>

The HTML code

1
<a href="?act=delete&id=1234" onClick="return confirmSubmit()">Delete</a>

Leave a Reply

Your email address will not be published. Required fields are marked *