Number display.html
Number display.html
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dynamic Number Display</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
padding: 20px;
}
#display {
margin-top: 20px;
font-size: 24px;
color: #333;
}
</style>
</head>
<body>
<h1>Number Display</h1>
<input type="number" id="xValue" placeholder="Enter X value">
<button onclick="startSequence()">Start</button>
<div id="display"></div>
<script>
function startSequence() {
const x = parseInt(document.getElementById('xValue').value);
let count = 0;
const interval = setInterval(() => {
if (count >= x) {
clearInterval(interval); // Stop the interval when count
reaches X
document.getElementById('display').innerText = 'Sequence
completed!';
} else {
document.getElementById('display').innerText =
Math.floor(Math.random() * x);
count++;
}
}, x * 1000); // Multiply by 1000 to convert seconds to milliseconds
}
</script>
</body>
</html>