I am currently in the process of developing a unique egg timer application that allows users to input values through various form select tags. However, I have encountered a NaN error when trying to set the timer with the JavaScript code provided below. Here is a section of the HTML and the JavaScript code I am working on:
<html>
<head>
<script language = "javascript" type = "text/javascript">
var minutes
var miuntes=setInterval(timer, 1000); //1000 will run it every 1 second
function timer(m)
{
minutes = m;
minutes=minutes-1;
if (minutes <= 0)
{
clearInterval(minutes);
//timer ended, do something here
return;
}
document.getElementById("txt").innerHTML=minutes + "minutes";
}
function checktimer()
{
var checkbox1 = form.preference.value;
var checkbox2 = form.eggsize.value;
var checkbox3 = form.suacepansize.value;
if(checkbox1 == 1 && checkbox2 == 1 && checkbox3 == 1)
{
m = 3;
s = 0;
}
timer(m);
}
</script>
</head>
<body>
<div id = "txt"> </div>
<form id="form" onclick ="checktimer()">
<div class = "question">
<div class="circle"> <h2 class = "whiteh2"> 1 </h2></div>
<div class="question-text"><h6>How do you like your egg? </h6> </div>
<select id="prefernce" name ="preference">
<option value="1">Soft</option>
<option value="2">Medium</option>
<option value="3">Hard</option>
</select>
</div>
<div class = "question">
<div class="circle"> <h2 class = "whiteh2"> 2 </h2></div>
<div class="question-text"><h6>What size is your egg? </h6> </div>
<select id="eggsize" name = "eggsize">
<option value="1">Small</option>
<option value="2">Medium</option>
<option value="3">Large</option>
</select>
</div>
<div class = "question">
<div class="circle"> <h2 class = "whiteh2"> 3 </h2></div>
<div class="question-text"><h6>What size is the saucepan? </h6> </div>
<select id="saucepansize" name = "suacepansize">
<option value="1">Small</option>
<option value="2">Medium</option>
<option value="3">Large</option>
</select>
</div>
<div class = "question">
<input type="submit" id="button" name="submit" value = "Go" onclick="checktimer()"/> <br/>
</div>
</form>
</div>
</body>
</html>