I'm currently into a place where I call an Api with Ajax to delete a Client from a table I've. The thing is, that I've previously tried to make a check before ajax is executed, but it doesn't seem to work.
So this time, when Delete button is clicked I want to check first if the user is sure he wants to delete the client, and if true, execute the function to delete it.
The thing is, I've the id into the button like this:
<td class="text-center">
<a type="button" class="btn btn-danger" value=('+value.id+') onclick="sureAboutDelete()">Delete Client</a>
</td>
And then in .js file I'm trying that:
// Check if user wants to delete Client
function sureAboutDelete(){
console.log((event.target));
// var id = Get the value of value attribute
// Ask for the user if he/she is sure about deleting
If (true){
// delete client using ID taken
deleteClient($id);
} else {
// Just close prompt
return;
}
}
When using "(event.target)" I can see all the button with the attributes, but putting "(event.target).val" or like this, I can not take the id I want.
Any suggestion?
Thanks !