0

how to make a checkbox remain unchanged whether it is checked or unchecked though the page is refreshed manually or automatically? Can you please provide code in your answer?

<html>
<head>
<script>
function checkFirstVisit() {
  if(document.cookie.indexOf('mycookie')==-1) {
    // cookie doesn't exist, create it now
    document.cookie = 'mycookie=1';
  }
  else {
    // not first visit, so alert
    alert("refreshed");
    checked();
  }
}

function checked()
{
var ins1=document.getElementById("id");

if(ins1.checked)
    ins1.checked=true;

}
</script>
</head>
<body onLoad="checkFirstVisit()">
<input type="checkbox" id="id" >
<input type="checkbox" id="id" >
<input type="checkbox" id="id">
<input type="checkbox" id="id">
<input type="checkbox" id="id">
</body>
</html>
4

0 回答 0