JavaScript can't deal with databases on its own, it just can tell the browser what to do and is only loaded after the server has submitted the page to the browser. So I guess you'll have to work with AJAX. This is quite simple using jQuery:
...
$.post('process.php', {id:curid, date : when}, function(data) {
alert(data);
//data contains all output from process.php,
//either in json-format if you jsonencode a results-array
//or just a simple string you echo in the php
return false; //prevent from reloading the page
});
...
Your process.php could look something like:
<?php
$curid = $_POST['id'];
$when = $_POST['date'];
//run the query
echo jsonencode($results_array);
//or check if query succeeded and echo e.g. 'ok' or 'failed'
?>
You get the idea... ;)
//EDIT:
You should probably use the jQuery UI for the dialog-box to avoid the message as described in the comments. It could be something like this:
<div id="dialog_box" style="display: none;">
Really delete?
</div>
$('#dialog_box').dialog({
title: 'Really delete this stuff?',
width: 500,
height: 200,
modal: true,
resizable: false,
draggable: false,
buttons: [{
text: 'Yep, delete it!',
click: function(){
//do the post
}
},
{
text: 'Nope, my bad!',
click: function() {
$(this).dialog('close');
}
}]
});