-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandNumgenerator.html
More file actions
36 lines (36 loc) · 1.49 KB
/
randNumgenerator.html
File metadata and controls
36 lines (36 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Random Number Generator</title>
<style>
input {
max-width: 50px;
}
</style>
</head>
<body>
<p>Generate <input type="number" id="amount" value="100"> random numbers.</p>
<p>Generate random numbers between <input type="number" id="min" value="1"> and <input type="number" id="max" value="100">.</p>
<p>Format in <input type="number" id="cols" value="10"> columns.</p>
<button onclick="getRNDNum()">Generate</button>
<div id="result"></div>
<script>
let result = document.getElementById('result');
function getRNDNum() {
let amount = parseInt(document.getElementById('amount').value);
let cols = parseInt(document.getElementById('cols').value);
let min = parseInt(document.getElementById('min').value);
let max = parseInt(document.getElementById('max').value);
let output = ''
for (let i = 0; i < amount; i++) {
let randomNum = Math.floor(Math.random() * (max - min + 1)) + min;
output += randomNum;
if (i < amount - 1) output += ', ';
if ((i + 1) % cols === 0) output += '<br>';
};
result.innerHTML=output
};
</script>
</body>
</html>