How to put link in modal message box with a unique ID
I have this link before with normal confirmation to delete a user (a
common prompt that pop up in the browser)
function cancel() {
var msg = "Are you sure you want to cancel?";
var answer = confirm(msg);
if (answer){
document.frm.submit();
return false;
}
}
<td><a href="cancelations/cancelreservation.php?ip_cancelID=<?php echo
$iprow['ReserveID']; ?>" onclick="cancel(); return false"><img
src="../images/customerImages/cancel.png" style="width:80px;"/></a></td>
I have searched for some modal confirmation box to remove a user by its
unique ID and I changed my above code to this:
function removeUser(id){
var txt = 'Are you sure you want to remove this user?<input
type="hidden" id="userid" name="userid" value="'+ id +'" />';
$.prompt(txt,{
buttons:{Delete:true, Cancel:false},
close: function(e,v,m,f){
if(v){
var uid = f.userid;
//$.post('removeuser.php',{userid:f.userid},
callback:function(data){
// if(data == 'true'){
$('#userid'+uid).hide('slow', function(){
$(this).remove(); });
// }else{ $.prompt('An Error Occured while
removing this user'); }
//});
}
else{}
}
});
}
<td><a href="cancelations/cancelreservation.php?ica_cancelID=<?php echo
$icarow['ReserveID']; ?>" class="deleteuser" onclick="removeUser(1);"><img
src="../images/customerImages/cancel.png" style="width:80px;"/></a></td>
There is a problem inside the , the when I click it the modal shows but
the page loads and go to the link (the link is where the process of
deleting the user/data) without clicking any of the buttons in the modal
so I change it to this:
<td><a href="javascript:;"><img src="../images/customerImages/cancel.png"
style="width:80px;" class="deleteuser" onclick="removeUser(1);"/></a></td>
I got rid the link now the problem is how can I go to this link
"cancelations/cancelreservation.php"?ica_cancelID with this ID
$icarow['ReserveID']; in function removeUser(id) ???
Please help my mind is still dumb in javascript/jquery syntax and this is
my first time using modals
No comments:
Post a Comment