vendredi 25 décembre 2020

save checkbox status after page reload

help to make the checkbox status persist after reloading the page, thanks!

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js" type="text/javascript"></script>


<input type="checkbox" name="enable" id="enable" />Enable
<input type="text" id="name" name="name" disabled />


<script>

window.onload=function(){
    document.getElementById('enable').onchange=function(){
        var txt = document.getElementById('name');
        txt.disabled = !this.checked;
    };
};

</script>



Aucun commentaire:

Enregistrer un commentaire