I need to keep the previous state of the checked variable from input
type checkbox
after the page loads. In the current state, every time it is loaded, checkbox
returns the unchecked condition.
I would like a solution through JavaScript.
<html>
<head>
<title>CSS SWITCH</title>
<meta charset="UTF-8">
<script type="text/javascript">
function ChecksVerify() {
var aChk = document.getElementsByName("item");
for (var i=0;i<aChk.length;i++){
if (aChk[i].checked == true){
aChk[i].value = "?f=on";
} else {
aChk[i].value = "?f=off";
}
window.location.assign(aChk[i].value);
alert(aChk[i].value + " enviado");
}
}
</script>
</head>
<body>
<div class="switch__container">
<p align='center'>
<input type="checkbox" name="item" onclick="ChecksVerify()">
<label for="switch-shadow"></label>
</p>
</div>
</body>
</html>