-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRandom Number Generator
113 lines (100 loc) · 2.5 KB
/
Random Number Generator
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE html>
<html>
<head>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f2f2f2;
}
.container {
background-color: #fff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
padding: 30px;
text-align: center;
width: 300px;
}
h1 {
font-size: 24px;
margin-bottom: 20px;
}
.input-section {
margin-bottom: 20px;
}
input[type="number"] {
padding: 8px;
margin: 10px 5px;
width: 80px;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
padding: 10px 20px;
margin-top: 10px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #45a049;
}
button:active {
background-color: #3e8e41;
}
#randomNumber {
font-size: 24px;
font-weight: bold;
margin: 20px 0;
color: #333;
}
#reset {
background-color: #f44336;
margin-top: 10px;
}
#reset:hover {
background-color: #e53935;
}
</style>
</head>
<body>
<div class="container">
<h1>Random Number Generator</h1>
<div class="input-section">
<label for="min">Minimum:</label>
<input type="number" id="min" value="1">
<label for="max">Maximum:</label>
<input type="number" id="max" value="100">
</div>
<button id="generate">Generate Random Number</button>
<div class="result">
<p id="randomNumber">Click the button to generate</p>
</div>
<button id="reset">Reset</button>
</div>
<script>
document.getElementById('generate').addEventListener('click', function() {
const min = parseInt(document.getElementById('min').value);
const max = parseInt(document.getElementById('max').value);
const randomNumber = Math.floor(Math.random() * (max - min + 1)) + min;
document.getElementById('randomNumber').innerText = randomNumber;
});
document.getElementById('reset').addEventListener('click', function() {
document.getElementById('randomNumber').innerText = 'Click the button to generate';
document.getElementById('min').value = 1;
document.getElementById('max').value = 100;
});
</script>
</body>
</html>