I wrote the following js. I want it to count down inside the div-element. Please help. I've exhausted everything I could think of. Is this a problem in the HTML or am I just not passing things correctly in my js code?
<html>
<head>
<title>Counter</title>
<script>
var el, usr_t, split_list, mins, secs;
function getValues() {
el = document.getElementById("timer");
usr_t = document.getElementById("time").value;
split_list = usr_t.split(":").map(Number);
mins = split_list[0];
secs = split_list[1];
while (mins >= 0) {
for (var i = secs; i > 0; i--) {
setDelay(i);
}
secs = 59;
mins--;
}
}
function setDelay(i) {
setTimeout(function() {
el.innerHTML = (mins + ":" + secs);
}, 1000);
}
</script>
</head>
<body>
<form>
Enter your time: (mm:ss)
<br>
<input type="text" id="time">
<br>
<input type="submit" value="Start" onclick="getValues()">
</form>
<div id="timer"></div>
</body>
</html>