-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
67 lines (65 loc) · 2.51 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
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<title>BMI Calculator</title>
<link rel="stylesheet" type="text/css" href="bmi_calculator.css">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>
<div class="container">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark rounded">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">CALCULATE YOUR BMI</a>
</li>
</ul>
</div>
</nav>
</div>
<div class="container">
<h2>BMI Calculator</h2><br>
<div class="row">
<div class="col-sm">
<form id="bmiForm">
Height feet:<br>
<input type="number" id="myNumber1" placeholder="Enter height Feet"><br><br>
Height inches:<br>
<input type="number" id="myNumber2" placeholder="Enter height inches"><br><br>
Weight:<br>
<input type="number" id="myNumber3" placeholder="Enter weight"><br><br><br>
<button type="button" class="btn btn-info" onclick="calcBmi()">Calculate your BMI</button>
<button type="button" class="btn btn-info" onclick="resetBmi()">Reset</button><br>
<hr>
<p id="displayBmi"></p>
</form>
</div>
<div class="col-sm">
<img src="stepOnScale.png" alt="scale">
</div>
</div>
</div>
<!-- begin javascript -->
<script>
//function to calculate the bmi numbers inputed
const calcBmi = () => {
let heightFeet = document.getElementById("myNumber1").value;
let heightInch = document.getElementById("myNumber2").value;
//calculates the total height in feet and inches
let heightTotal = (parseInt(heightFeet) * 12)+ parseInt(heightInch);
let weight = document.getElementById("myNumber3").value;
document.getElementById("displayBmi").innerHTML =
"Your body mass index number (BMI) is: " + Math.round((weight/Math.pow(heightTotal, 2) * 703));
}
//displays the calculated results
const bmiDisplay = document.getElementById("displayBmi");
const resetBmi = () => {
document.getElementById("bmiForm").reset();
bmiDisplay.textContent = null;
}
</script>
</body>
</html>