There
are sometime requirement that user should get a confirmation before performing
an action, i.e. for example when click on Delete link, you want a confirmation from user whether
he/she is really want to delete or they accidently clicked on delete link.
So
here I'm showing how you can show confirmation box.
<script type="text/javascript">
function
confirmDelete(delUrl) {
if
(confirm("Are you sure you want to delete
this record?")) {
return
true;
}
return
false;
}
</script>
|
And call this function as:
<a href="javascript:return confirmDelete();">Delete</a>
|
Another way
We
can write JavaScript confirm code inline as well:
<a onclick="javascript:return confirm('Are you sure you want to
delete this record?');">Delete</a>
|
Comments
Post a Comment