Простой список JavaScript
<h2><u>A Simple To-Do List</u></h2>
<input type="checkbox">
<input type="text" id="i1" onkeyup='saveValue(this);'/><br><br>
<input type="checkbox">
<input type="text" id="i2" onkeyup='saveValue(this);'/><br><br>
<input type="checkbox">
<input type="text" id="i3" onkeyup='saveValue(this);'/><br><br>
<input type="checkbox">
<input type="text" id="i4" onkeyup='saveValue(this);'/><br><br>
<script type="text/javascript">
document.getElementById("i1").value = getSavedValue("i1");
document.getElementById("i2").value = getSavedValue("i2");
document.getElementById("i3").value = getSavedValue("i3");
document.getElementById("i4").value = getSavedValue("i4");
function saveValue(e){
var id = e.id; // get the sender's id to save it .
var val = e.value; // get the value.
localStorage.setItem(id, val);// Every time user writing something, the localStorage's value will override .
}
//get the saved value function - return the value of "v" from localStorage.
function getSavedValue (v){
if (!localStorage.getItem(v)) {
return "";// You can change this to your defualt value.
}
return localStorage.getItem(v);
}
</script><hr>
Thomas coder