Alert only once after the execution of all the functions in JS
I have update(), delete(), addRow() in my Javascript, I need to update the input text field to Y if all of these functions executes.
I have written the JS and HTML code as below
Flag Change:<input type="text" id="FLAG_CHANGE" name="FLAG_CHANGE" value="N" onchange="updateFlag()">
function updateFlag()
{
$('[name=FLAG_CHANGE]').val('Y');
alert('alert sent to tech')
}
function delete(){
if(confirm("Are you sure you want to delete this data"))
{
var URL = 'deleteNotes&inspec_id='+inspec_id+'&OWNER='+OWNER;
syncAjaxCall("TDRequest",URL);
var eId =$("#popUpForm #e_Id").val();
updateFlag();
TDTable(eId);
}
else{
$("#STATUSDIVID").removeAttr('class').addClass('div-warning').html("You do not have permission to delete this record");
}
My requirement is whenever the user updates, deletes or add a row, alert should pop up only once after all the functions execute and the flag should of course be Y but in my case alert comes every time any of these operations are performed.
Can you please suggest?