Html 刷新后如何在jsp中刷新前检查复选框是否已选中

Html 刷新后如何在jsp中刷新前检查复选框是否已选中,html,jsp,Html,Jsp,如何使复选框在手动或自动刷新页面时保持不变(无论是否选中)? 你能在回答中提供代码吗 <html> <head> <script> function checkFirstVisit() { if(document.cookie.indexOf('mycookie')==-1) { // cookie doesn't exist, create it now document.cookie = 'mycookie=1'; } else

如何使复选框在手动或自动刷新页面时保持不变(无论是否选中)? 你能在回答中提供代码吗

<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>

运行此代码时会发生什么情况?如果我选中复选框,然后刷新页面,复选框将被取消选中…但我希望它保持选中状态..然后你需要获取表单提交上的参数,然后将其设置为请求属性,并检查是否已设置,然后检查/取消选中Accrodingly非常感谢..现在正在工作,欢迎您的到来。将其作为答案发布并接受答案