I have a form that does an update.
But I wanted to put a checkbox type input that when checked, changed the action of my form to delete.
I have a form that does an update.
But I wanted to put a checkbox type input that when checked, changed the action of my form to delete.
The simplest way to get this result:
function suaFuncao(option) {
if (option) {
document.getElementById("seu_form").action = "delete";
} else {
document.getElementById("seu_form").action = "update";
}
}
<form id="seu_form" action="update">
Deseja fazer um delete?<input type="checkbox" onclick="suaFuncao(this.checked)">
</form>