JSのコードで保存ができません
以下のコードなのですがnameの部分だけ保存ができません
なぜなのでしょうか
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name1="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" href="components/loader.css">
<script src="components/loader.js"></script>
</head>
<body>
<table border="3" align="center" style=border-spacing:0px;>
<tr>
<th width="20" height="30">Day</th>
<th width="80">name</th>
<th width="70">in</th>
<th width="100">out</th>
<th width="100">total</th>
</tr>
<tr>
<th><input type="text" id="day" style="width : 30px; height : 20px;"></th>
<td><input type="text" id="name" style="width : 80px; height : 20px;"></td>
<td><input type="text" id="in_m" style="width : 50px; height : 20px;"></td>
<td><input type="text" id="out_m" style="width : 50px; height : 20px;"></td>
<td><input type="text" id="total" style="width : 50px; height : 20px;"></td>
</tr>
</table>
<script>
//保存関係
var day = document.getElementById("day");
var name = document.getElementById("name");
var in_m = document.getElementById("in_m");
var out_m = document.getElementById("out_m");
var total = document.getElementById("total");
window.onload = function() {
var body_day = localStorage.getItem("day");
var body_name = localStorage.getItem("name");
var body_in_m = localStorage.getItem("in_m");
var body_out_m = localStorage.getItem("out_m");
var body_total = localStorage.getItem("total");
if (body_day != null) day.value = body_day;
if (body_name != null) name.value = body_name;
if (body_in_m != null) in_m.value = body_in_m;
if (body_out_m != null) out_m.value = body_out_m;
if (body_total != null) total.value = body_total;
}
day.onchange = function() {
localStorage.setItem("day",day.value);
}
name.onchange = function() {
localStorage.setItem("name",name.value);
}
in_m.onchange = function() {
localStorage.setItem("in_m",in_m.value);
}
out_m.onchange = function() {
localStorage.setItem("out_m",out_m.value);
}
total.onchange = function() {
localStorage.setItem("total",total.value);
}
</script>
</body>
</html>
補足
回答ありがとうございます ご教授していただいた通り <body> <input type = "checkbox" id = checkbox1>CHECK!!<br> <script> localStorage.setItem("checkbox1_checked",document.getElementById("checkbox1").checked); </script> </body> と記入したのですが更新すると元通りになってしまいます <body> <input type = "checkbox" onclick="test1();" id = checkbox1>CHECK!!<br> <script> function test1(){ localStorage.setItem("checkbox1_checked",document.getElementById("checkbox1").checked); } </script> こういう風にも書いてみたのですが・・・。