jeudi 19 février 2015

Deselect checkbox if confirm is false

I have a series of checkboxes that uses can click on which will cause a form to submit. Before I submit the form I wasn't them to confirm that's what they want to do. I can't seem to uncheck the box if they choose cancel and I'm not sure what is wrong with the code I'm using. Can anyone help?



<input type="checkbox" name="box_1" id="box_1" value="1" onclick="javascript:if (confirm('Are you sure?')){this.form.submit();}else{document.getElementById('box_1').checked = 'false';};" />


Am I missing something obvious?





Aucun commentaire:

Enregistrer un commentaire