-
Notifications
You must be signed in to change notification settings - Fork 0
/
bmi.html
188 lines (170 loc) · 7.9 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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<!DOCTYPE html>
<head>
<!-- Meta Tag -->
<title>Enhao | Web Developer</title>
<meta charset="UTF-8">
<meta name="description" content="Enhao | Web Developer">
<meta name="keywords" content="personal, portfolio, enhao, web developer, enhaotech">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Link -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/css/bootstrap-select.min.css">
<link rel='stylesheet prefetch' href='http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css'>
<link href="css/dashboard.css" rel="stylesheet">
<link href="css/radio.css" rel="stylesheet">
<!-- Google Analytics -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-168754699-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-168754699-1');
</script>
<style>
/*CSS Styling*/
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
.form-group{
margin-bottom: 20px;
}
.error_msg{
color: red;
display: none;
}
.tb_field{
height: 2.4em;
font-size: 1.2em;
}
#submitbtn, #back_btn{
width:100%;
margin-bottom: 10px;
background-color: #1fa6a8;
color: white;
font-size: 1.5em;
}
#submitbtn:hover{
border:1.5px solid green;
}
#bmi_value{
font-size: 25px;
padding: 4px 10px;
font-weight: bolder;
}
@media (max-width: 767px) {
#bmi_value{font-size: 36px;}
}
@media (max-width:900px){
h2{font-size: 1.8em;}
}
</style>
</head>
<body>
<!-- Body content -->
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid" style="background-color: #1fa6a8;">
<div class="navbar-header">
<a class="navbar-brand" href="index.html" style="color:white;">EnhaoTECH</a>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="main">
<h1 class="page-header" style="text-align: center;">BMI Calculator</h1>
<form class="form-horizontal" id="bmi_form" onsubmit="return false" >
<!-- Row 1 -->
<div class="form-group" style="margin-bottom: 25px;">
<label class="control-label col-sm-2 col-sm-offset-2" for="weight">Weight</label>
<div class="col-sm-6">
<div class="input-group">
<input value="65" class="form-control tb_field" id="weight" name="weight" type="number" >
<span class="input-group-addon">Kg</span>
</div>
<span id="loan_amt_error" class="error_msg">Please enter a valid loan amount</span>
</div>
</div>
<!-- Row 2 -->
<div class="form-group" style="margin-bottom: 25px;">
<label class="control-label col-sm-2 col-sm-offset-2" for="height" id="height_text">Height</label>
<div class="col-sm-6">
<div class="input-group">
<input value="166" class="form-control tb_field" id="height" name="height" type="number" >
<span class="input-group-addon">cm</span>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-4 col-sm-push-6">
<button id="submitbtn" type="submit" class="btn btn-default">Next</button>
</div>
</form>
<div id="user_result" style="display: none;">
<img class="col-xs-8 col-xs-offset-2 col-sm-3 col-sm-offset-2" src="images/scale.png" alt="Weighting Scale">
<div class="col-xs-12 col-sm-5">
<h2 style="text-align: center; padding-bottom: 15px;">Your BMI Results</h2>
<div class="col-sm-12" style="border-bottom: 1px solid #b1b2b5; text-align: center;">
<label class="col-sm-6">Your BMI:</label>
<span id="bmi_value" class="col-sm-6"></span>
</div>
<span class="col-sm-12" style="height: 20px; display: inline-block;"> </span>
<span id="bmi_suggestion" class="col-xs-12" style="font-size: 24px;"></span>
<button id="back_btn" class="btn btn-default" style="margin-top: 12px;">Back</button>
</div>
</div>
</div>
</div>
</div>
<!-- Javascript Scripts or other scripts links -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/bootstrap-select.min.js"></script>
<!-- Change to currency format -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.inputmask/3.3.4/jquery.inputmask.bundle.js"></script>
<!-- Start Javascripts -->
<script>
$(document).ready(function() {
// Submit BMI
$("#submitbtn").click(function(){
var height_m = "",
BMI = ""
$("#weight").val()
// Caculations for BMI
height_m = Math.pow(($("#height").val() / 100),2)
BMI = ($("#weight").val() / height_m).toFixed(2)
bmi_results(BMI)
});
$("#back_btn").click(function(){
// Hide and display the appropriate information
$("#bmi_form").show()
$("#user_result").css("display", "none")
});
// BMI results class
function bmi_results(BMI){
// Hide and display the appropriate information
$("#bmi_form").hide()
$("#user_result").css("display", "block")
$("#bmi_value").text(BMI)
// Risk Level
if (BMI < 18){
// Underweight
$("#bmi_suggestion").text("You are underweight!")
$("#bmi_suggestion").css("color", "red")
}
else if (BMI >= 18 && BMI <= 25){
// Healthy
$("#bmi_suggestion").text("Looking Healthy! You are in the normal range!")
$("#bmi_suggestion").css("color", "green")
}
else{
// Overweight
$("#bmi_suggestion").text("Seems like you eaten abit too much recently! Try losing some weight!")
$("#bmi_suggestion").css("color", "red")
}
};
});
</script>
</body>