Yes, I managed to solve it with HTML & Javascript:
<!DOCTYPE html>
<html>
<head>
<title>Todo List</title>
</head>
<body>
<h1>To do:</h1>
<label><input type="checkbox" id="task1"> Task 1</label><br>
<label><input type="checkbox" id="task2"> Task 2</label><br>
<label><input type="checkbox" id="task3"> Task 3</label><br>
<script src="script.js"></script>
</body>
</html>
// Function to set a cookie
function setCookie(cname, cvalue) {
var d = new Date();
d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000)); // 30 days expiry
var expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
// Function to get a cookie by name
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
// Function to update checkbox and cookie status
function updateStatus(taskId) {
var taskElement = document.getElementById(taskId);
var isChecked = taskElement.checked ? "true" : "false";
setCookie(taskId, isChecked);
}
// Function to initialize the checkbox statuses from cookies
function initializeStatus() {
for (var i = 1; i <= 3; i++) {
var taskId = "task" + i;
var cookieValue = getCookie(taskId);
if (cookieValue === "true") {
document.getElementById(taskId).checked = true;
}
document.getElementById(taskId).addEventListener("change", function() {
updateStatus(this.id);
});
}
}
// Call the initialize function when the page loads
initializeStatus();
What this does is to set and get cookies. When a checkbox is clicked, its status is stored in a cookie. When the page is reloaded, the checkboxes statuses are read from the cookies and restored accordingly