Q:

Delete confirmation for html form

I would like to add a delete confirmation  to my form button 
Possible javascript to use??
<script type="text/javascript"> 
function confirmDelete() { 
return confirm("Are you sure you want to delete?");   
} 
</script> 

This is currently working inside my form.
<input type="button" onclick="parent.location='<?php echo "delete.php?id=" . $people['id'] ?>'" value='Delete'>

How can I integrate the javascript into the onclick event? Either using the above javascript or any other way that may be better

A:

It's possible :)
On the  tag, use the attribute onsubmit like this :
<form onsubmit="return confirm('Are you sure?');">

or using a method
<form onsubmit="return myMethod">

The same for a button on onclick event. If it return false, it will be not clicked.
Remember, if the method return false, the form will not be submited

A:

Bind your event handler in javascript.
<input type="button" id="delete" value='Delete' />

document.getElementById('delete').onclick = function () {
    if (confirm('Are you sure?')) {
        parent.location='<?php echo "delete.php?id=" . $people['id'] ?>';
    }
};

