My web page deletes a row in a table and save it automatically in database. I need a messageBox
after clicking on delete button, with two buttons "save" and "No". Delete function on jsp is below:
function deleteFileRow(rowCount)
{
$.ajax(
{
url: 'deleteRow.htm?rowIndex='+rowCount+"&action=delete&id="+${id},
success: function(data)
{
document.location.reload();
}
});
}
Please help me in doing this.
Use jquery confirm box to add yes or no.
ConfirmDialog('Are you sure');
function ConfirmDialog(message){
$('<div></div>').appendTo('body')
.html('<div><h6>'+message+'?</h6></div>')
.dialog({
modal: true, title: 'Delete message', zIndex: 10000, autoOpen: true,
width: 'auto', resizable: false,
buttons: {
Yes: function () {
// $(obj).removeAttr('onclick');
// $(obj).parents('.Parent').remove();
$(this).dialog("close");
},
No: function () {
$(this).dialog("close");
}
},
close: function (event, ui) {
$(this).remove();
}
});
};
here you can find how to pop a messageBox with yes/no and question in javascript and you can use that if you aren't determined on "save"/"no"
var nRslt = app.alert ("Press \"yes\" to save\n" + "Press \"No\" to delete";, 2, 2, "Submit Validation");
if(nRslt == 4) { // User Pressed Yes, Do submission
this.submitForm(...);
}
The problem is solved with the following code:
function deleteFileRow(rowCount){
var stay=confirm("Are you sure, You want to delete Row? Click "ok" to confirm, "cancel" Otherwise")
if(stay)
{
$.ajax({
url: 'deleteRow.htm?rowIndex='+rowCount+"&action=delete&testid="+${testid},
success: function(data) {
document.location.reload();
}
});
}
}
Ajax call would be inside "confirm".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.