-
Notifications
You must be signed in to change notification settings - Fork 1
/
bmi.html
56 lines (55 loc) · 2.38 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fitness Tracking</title>
<link rel="stylesheet" href="bmi.css">
</head>
<body background="fitness cheake.jpg">
<div class = "container">
<div class="form-box">
<form name = "fitness" method = "get" action = "suggestion.html">
<caption><h2>BMI Calculator</h2></caption>
<table>
<tr>
<td>Weight (in kg): </td>
<div class = "input-field">
<td><input type = "number" name = "weight" step = "0.01" placeholder = "Enter Weight" required></td>
</div>
</tr>
<tr>
<td>Height (in m): </td>
<div class = "input-field">
<td><input type = "number" name = "height" step = "0.01" placeholder = "Enter Height" required></td>
</div>
</tr>
</table>
<div class = "btn-field">
<td><input type = "button" value = "Calculate BMI" class = "button" onClick = "calculateBMI()"></td>
</div>
<br>
<p id = "result"></p>
</form>
</div>
</div>
<script>
function calculateBMI(){
weight = parseFloat(document.fitness.weight.value);
height = parseFloat(document.fitness.height.value);
var bmi = weight / (height * height);
if (bmi < 18.5){
alert("BMI: " + bmi.toFixed(2) + "\nYou are underweight but don't worry, try to follow our mentioned Fitness Plan.");
}
else if (bmi >= 18.5 && bmi < 25){
alert("BMI: " + bmi.toFixed(2) + "\nYou are normal and to remain fit, try to follow our mentioned Fitness Plan.");
}
else{
alert("BMI: " + bmi.toFixed(2) + "\nYou are overweight but don't worry, try to follow our mentioned Fitness Plan.");
}
var newWindow = window.open("suggestions.html", "_blank");
}
</script>
<br><br><a href = "index.html"><h1>Go Back to Main Page...</h1></a><br>
</body>
</html>