I'm dealing with editing reservations and adjusting payments based on this. If a reservation is extended, then I need to charge the customer for the extent of this, likewise, if it's shortened I need to refund.
I tried something like this (without actually POSTing anything, just a confirm box), but even when pressed cancel it submitted the form anyway.
<?php echo $this->Form->create('edit',array('onsubmit'=>'return check_dates()')); ?>
//rest of form here
<script>
function check_dates(){
//make POST request to check previous reservation duration
if(data.duration == 'longer'){
confirm('The guest will be charged $X. Click OK to continue');
}
if(data.duration == 'shorter'){
confirm('The guest will be refunded $X. Click OK to continue');
}
if(data.duration == 'no_change'){
confirm('Click OK to continue')
}
}
</script>
Is it possible to do something like this? As I mentioned previously, when I pressed cancel the form submitted anyway.