-
Notifications
You must be signed in to change notification settings - Fork 0
/
bmi.html
79 lines (71 loc) · 2.68 KB
/
bmi.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="bmi.css">
</head>
<body>
<nav>
<img src="logo.png" alt="" >
<h1>Fitness Studio</h1>
<ul>
<li><a href="new.html">Home</a></li>
<li><a href="course.html">Course</a></li>
<li><a href="bmi.html">BMI Calculator</a></li>
<li><a href="product.html">Product</a></li>
<li><a href="about.html">About Us</a></li>
<button><a href="login.html">Login</a></button>
</ul>
</nav>
<hr>
<div class="container">
<h1>BMI Calculator</h1>
<form id="bmiForm">
<div class="form-group">
<label for="weight">Weight (kg):</label>
<input type="number" id="weight" name="weight" required>
</div>
<div class="form-group">
<label for="height">Height (cm):</label>
<input type="number" id="height" name="height" required>
</div>
<div class="form-group">
<input type="submit" value="Calculate BMI" class="btn">
</div>
</form>
<div id="result" class="result"></div>
</div>
<script>
document.getElementById("bmiForm").addEventListener("submit", function(event) {
event.preventDefault();
calculateBMI();
});
function calculateBMI() {
var weight = parseFloat(document.getElementById("weight").value);
var height = parseFloat(document.getElementById("height").value);
if (weight && height) {
var bmi = weight / ((height / 100) * (height / 100));
var result = "Your BMI is " + bmi.toFixed(2);
if (bmi < 18.5) {
result += " - Underweight";
} else if (bmi >= 18.5 && bmi < 25) {
result += " - Normal weight";
} else if (bmi >= 25 && bmi < 30) {
result += " - Overweight";
} else {
result += " - Obesity";
}
document.getElementById("result").textContent = result;
}
}
</script><br><br><br><br><br><br>
<br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br>
<br><br><br><br>
<footer>
<p>© 2023 Gym Website. All rights reserved.</p>
</footer>
</body>
</html>