0
I have several checkboxes in a form, which will be marked by the user. If you want, you can clear them all by clicking on a button, as shown below:
tried using this function in javascript:
function myFunctionClear() {
for (i = 0; i < document.selecao.elements.length; i++)
if (document.selecao.elements[i].type == "checkbox")
document.selecao.elements[i].checked = 0
}
on my button
<button class='btn custom' onclick="myFunctionClear()">Limpar Seleção</button>
but for some reason it’s not working. Stackoverflow’s other answer I found (Check/Deselect Checkbox from a button) shows a button that marks and marks all checkboxes, but I only want the option to uncheck. link to the jsfidlle: https://jsfiddle.net/elenderg/tdvqp4xL/
Check/Deselect Checkbox from a button
– rray
I imagine all checkboxs have the same name, can pick them up and give
checked=false
in all or catch by tag.– rray