I'm trying to make a small program to take 3 user inputs, and make a loop out of it. For example, user says he wants to start from the number 5 up to the number 25 and count by 5, so the program will execute : "5 10 15..."
But I seem to fail and I couldn't find what I'm doing wrong.
HTML/JS
<!DOCTYPE HTML>
<html>
<head>
<title>Counter</title>
<link rel="Stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h1>The Counter</h1>
<form>
<fieldset>
<label for="firstNum"> Start from </label>
<input type = "text" id = "firstNum"> </input>
<label for="lastNum"> Up to </label>
<input type="text" id="lastNum"> </input>
<label for="countBy"> Count By </label>
<input type= "text" id="countBy"> </input> </br>
<button onclick = "startCount()" type = "button"> Start the Counter! </button>
</fieldset>
</form>
<p id="loopHere"></p>
<script>
function startCount() {
var firstNum = document.getElementById("firstNum");
var lastNum = document.getElementById("lastNum");
var countBy = document.getElementById("countBy");//finish getElements
var a = firstNum.value;
var b = lastNum.value;
var c = countBy.value;//finish getting values
for(i = a; i <= b; i += c) {
document.write(i + "</br>");
}//finish loop
}//finish function startCount()
</script>
</body>
</html>
CSS
fieldset {
width: 50%;
margin-left: auto;
margin-right: auto;
}
input {
width: 20%;
color: red;
}
h1 {
text-align: center;
}
button {
margin-left: auto;
margin-right: auto;
}
Thanks.