I can’t believe I got this code to work. I made a basic counter white text in a black box and it increases every 15 seconds. But my Java is pretty rusty, and I need this for my website on Wix (ugh) and It only counts for the users’ sessions. It doesn’t keep track of what the number is through out the month and report that whenever someone visits the site. Just tell me is that going to be way more difficult as far as coding, or is it a local storage setting I have to change thru Wix? I’m trying to run a non-profit, and I just don’t have the funds for a programmer right now. (I took out a couple of operators and and what not because it’s trying to run some of my code in the reply lol)
html lang="en"
head
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Number Box</title>
<style>
.box {
background-color: black;
color: white;
font-size: 48pt;
padding: 10px;
text-align: center;
}
</style>
</head>
<body>
<div class="box" id="number-box">1</div>
<script>
let numberBox = document.getElementById("number-box");
let counter = parseInt(localStorage.getItem("counter")) || 1;
function updateNumber() {
let today = new Date();
let daysInMonth = new Date(today.getFullYear(), today.getMonth() + 1, 0).getDate();
if (today.getDate() === 1) {
counter = 1;
} else if (today.getDate() === daysInMonth) {
clearInterval(intervalId);
} else {
counter++;
}
numberBox.innerHTML = counter;
localStorage.setItem("counter", counter);
}
let intervalId = setInterval(updateNumber, 15000);
</script>
</body>
</html>