0
well I’m doing a college job, and has a file listing screen, at the time of deleting I created a button with onclick, I do not understand much of javascript, however following the logic of if Else it should run only the action if it were true, more even if I cancel it runs;
<script>
function apagar(){
var res = confirm("Deseja Apagar a questão ?");
if (res == false){
var href = this.href;
}else{
alert("Cancelado");
}
}
</script>
<a href="apagar_questao.php"><button type="button" class="btn btn-danger" id="btn_apagar" onclick="apagar()">Apagar</button></a>
In your if condition it should not be
if(res == true)
nay?– Miyukii
any of the two that I place it executes the action, being true or false it executes the href
– caique santos
The problem is that you should not put a button inside a link. Link is link, button is button, one should not mix the two things.
– Sam