I would like to send an id from the hidden input type in the form, when a confirmation message pops up and user clicks ok. Right now I cant even make this code without the confirmation popup work, no errors, just a refresh and nothing happens. You may be thinking why I need to confirm adding an item to a cart but that's because I also need to delete an item from the database later on.
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#add').click(function(){
var id = $("#get_id").val()
$.confirm({
'title' : 'Delete Confirmation',
'message' : 'You are about to delete this User.Continue?',
'buttons' : {
'Yes' : {
'action': function(){$a.ajax({
url: 'http://localhost/com/index.php/shopping_basket/view_basket',
type: 'POST',
data: { id: id },
success: (function(){
alert('added' + id);
});
}
},
'No' : {
'action': function(){} // Nothing to do in this case. You can as well omit the action property.
}
}
});
});
});
</script>
the form
<form id="basket" method="post" action="">
<input type="hidden" id="get_id" value="<?php echo $id ?>">
<input type="submit" id="add" value="Add">
</form>
btw what's the difference in using window.location.href to send something instead of this?