I have a page with save button, but every time it is clicked the script appears that the information has been saved and exits the page. My goal is for him not to quit, but I looked at the code and I did not understand why he was leaving. Follow the button:
<div class="row">
<div class="col-md-6 botao">
<button type="submit" class="btn btn-primary form-control" name="button" id="button">Salvar</button>
</div>
<div class="col-md-6 botao" >
<button type="button" name="button" id="button" class="btn btn-danger form-control">Cancelar</button>
</div>
Follow the script:
<script>
var retorna = function () {
window.location = "a_pagina_anterior.php";
}
var button = document.querySelector("#button");
button.onclick = retorna;
</script>