-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
56 lines (53 loc) · 1.41 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>BMI Calculator</title>
<link rel="stylesheet" href="/styles.css" />
<style>
body{
background-color: #212121;
color: white;
display: flex;
justify-content: center;
align-items: center;
margin: 50px;
padding: 50px;
}
div{
margin: 25px;
padding: 25px;
}
.button{
margin: 15px;
padding: 5px;
}
</style>
</head>
<body>
<div class="container">
<h1>BMI Calculator</h1>
<label for="height">Height (m):</label>
<input type="number" id="height" placeholder="Enter height in meters" />
<label for="weight">Weight (kg):</label>
<input
type="number"
id="weight"
placeholder="Enter weight in kilograms"
/>
<button id="calcBtn">Calculate BMI</button>
<div id="result"></div>
</div>
<script src="/index.js"></script>
<script>function calculateBMI(height, weight) {
return weight / (height * height);
}
document.getElementById("calcBtn").addEventListener("click", function () {
let height = document.getElementById("height").value;
let weight = document.getElementById("weight").value;
let BMI = calculateBMI(height, weight);
document.getElementById("result").innerText = "Your BMI is: " + BMI;
});</script>
</body>
</html>