I have a functionality so that when you want to delete a Patient when you click delete, it asks if you really want to delete it or not.
It shows the question, but when I give it to cancel it deletes it anyway and if I give it to accept, the same thing happens.
The onClick
to call the JavaScript function is inside a <tr>
, that <tr>
principal also has a onClick
, I don't know if that can cause a conflict.
This is the code used:
JS:
function irAWeb(event) {
if (confirm("¿Quieres ir a la página del Mensajeitor?") == false) {
event.stopPropagation();
event.preventDefault();
return false;
}
return true;
}
HTML:
<a onclick="return irAWeb();" href='pagines/esborrar.asp?id=<%=rs("Numero")%>&que=<%=nomfitxer%>'> <img src="images/delete.gif" border="0" alt="Borrar" /> </a>
The problem is because you forgot to pass
event
when calling the functionirAWeb
in theonclick
.Solution:
Modify
HTML
it as follows:I would NOT be able to tell you why that happens, it happened to me sometimes and I solved it by adding one more line of code, where I get the result of
confirm
I know it doesn't seem to have any changes as it should be the same, but this way it works fine.