lundi 7 mars 2022

How do I keep checkbox unchecked even if it has checked attribute? [closed]

I have 2 checkboxes. Both of them checked as default. When user uncheck one of the option and move to next page, I store the selection in localStorage. However, when I go back to this page, both checkboxes are again ticked, even if I see the correct selection in localStorage. I know the reason is checked attribute. However, I don't know how to solve it because these 2 options needs to be checked as default. If you have any suggestion, I would really appreciate.

<input type="checkbox" name = "group1" id="cb1" value="opt1" checked>
<label for="opt1">Option 1</label>

<input type="checkbox" name = "group1" id="cb2" value="opt2" checked>
<label for="opt2>Option 2</label>



Aucun commentaire:

Enregistrer un commentaire