I am trying to make a simple dyna mic code but its not working not showing any result.
<!DOCTYPE html>
<head>
<title>Cl</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<table align="center">
<tr>
<td>First Number</td>
<td>
<input type="number" id="first-number">
</td>
</tr>
<tr>
<td>Last Number</td>
<td><input type="number" id="last-number"></td>
</tr>
<tr>
<td>Increment</td>
<td><input type="number" id="increment"></td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="Press" onclick="myFunction();">
</td>
</tr>
</table>
<script>
function myFunction() {
var first = Number(document.getElimentById("first-number").value);
var last = Number(document.getElimentById("last-number").value);
var inc = Number(document.getElimentById("increment").value);
if (first <= last) {
for (i = first; i <= last; i += inc) {
document.write(i + "<br>");
}
} else{
for (i = first; i >= last; i -= inc) {
document.write(i + "<br>");
}
}
}
</script>
</body>
</html>```
Top comments (2)
Hi, there is a typo in
document.getElimentById
, it isdocument.getElementById
skillforge.com/why-using-document-...