-
Notifications
You must be signed in to change notification settings - Fork 0
/
BMI_Calculator.html
86 lines (68 loc) · 2.9 KB
/
BMI_Calculator.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
80
81
82
83
84
85
86
<!DOCTYPE html>
<html lang="en">
<head>
<title>BMI Calculator</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<style>
body{
background-image: linear-gradient(rgba(0,0,0,0.3),rgba(0,0,0,0.3)), url('https://images.rawpixel.com/image_1300/czNmcy1wcml2YXRlL3Jhd3BpeGVsX2ltYWdlcy93ZWJzaXRlX2NvbnRlbnQvbHIvcm0zNzNiYXRjaDE1LTIxNy0wMS5qcGc.jpg?s=wJHDTeUvB4lPPWtEbivZzXqqCANd4wmXUDZHldblyi4');
background-repeat: no-repeat;
background-size: cover;
background-position: center;
width: 100%;
height: 100vh;
position: relative;
}
header{
width: 100%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
</style>
</head>
<body>
<header>
<div class="container">
<div class="card w-50 m-auto text-center">
<div class="card-header text-center bg-info text-white" > BMI Calculator </div>
<div class="card-body">
<form class="w-50 m-auto" onsubmit="return false">
<div class="form-group">
<label> Weight: </label>
<input type="text" name="" placeholder="Weight in kg" required id="weight" class="form-control">
</div>
<div class="form-group">
<label> Height: </label>
<input type="text" name="" placeholder="Height in feet" required id="height" class="form-control">
</div>
<div class="form-group">
<label class="text-danger"> BMI Value: </label>
<input type="number" name="" id="bmivalue" class="form-control">
</div>
<div>
<button type="submit" class="btn btn-success" onclick="getbmivalue()">Check BMI</button>
</div>
</form>
</div>
<div class="card-footer text-center bg-light"> A healthy BMI ranges between 19 and 25. </div>
</div>
</div>
</header>
<script>
function getbmivalue(){
var weight = document.getElementById('weight').value;
var height = document.getElementById('height').value;
height=height*12;
height=height*0.025; //Now height is in meter
var newbmivalue = weight/Math.pow(height,2);
newbmivalue=Math.round(newbmivalue);
document.getElementById('bmivalue').value=newbmivalue;
}
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>