-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
82 lines (44 loc) · 1.82 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!doctype html>
<html lang="eng">
<head>
<meta charset="utf-8">
<title>BMI Calculator</title>
<meta name="description" content="A tool to calculate your body mass index">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="/normalize.css">
</head>
<body>
<div class="center">
<div class="box">
<header>
<h1>BMI Calculator</h1>
</header>
<form name="formWeight">
<label for="height">Height(cm)</label>
<input type="number" id="height" name="height"><br><br>
<label for="weight">Weight(kg)</label>
<input type="number" id="weight" name="weight"><br><br>
<button type="button" onclick="myFunction()">Calculate</button>
</form>
<div id="result"></div>
</div>
</div>
<script>
function myFunction() {
// get the form
var weight = Number(document.getElementById("weight").value);
var height = Number(document.getElementById("height").value);
var result = weight / ((height / 100) * (height / 100));
var bmi = result.toFixed(2);
document.getElementById("result").innerHTML = "Your Bmi score is " + bmi;
};
</script>
<!-- Google Analytics: change UA-XXXXX-Y to be your site's ID. -->
<script>
window.ga = function () { ga.q.push(arguments) }; ga.q = []; ga.l = +new Date;
ga('create', 'UA-XXXXX-Y', 'auto'); ga('set', 'anonymizeIp', true); ga('set', 'transport', 'beacon'); ga('send', 'pageview')
</script>
<script src="https://www.google-analytics.com/analytics.js" async></script>
</body>
</html>