-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBMI.html
More file actions
63 lines (43 loc) · 1.21 KB
/
BMI.html
File metadata and controls
63 lines (43 loc) · 1.21 KB
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
<html>
<head>
<title>BMI Calculator</title>
<style>
body {background-color:rgb(232,232,232);
}
#textbox1 {width:41%;
}
#textbox2 {width:33%;
}
</style>
</head>
<body>
<label for="textbox1">Enter weight in lbs</label>
<input type="range" min=0 max=500 value=0 onmousemove="convert();" id="textbox1">
<label for="textbox2">Enter height in inches</label>
<input type="range" min=0 max=100 value=0 onmousemove="convert();" id="textbox2">
<p id="weight">Weight: 0</p>
<p id="height">Height: 0</p>
<p id="result">BMI: 0 </p>
<p id="good"></p>
<script>
convert=function() {
weightvalue = document.querySelector("#textbox1").value;
heightvalue = document.querySelector("#textbox2").value;
result = document.querySelector("#result");
weight = document.querySelector("#weight");
height = document.querySelector("#height");
x = (weightvalue * 703)/(heightvalue*heightvalue);
weight.innerHTML="Weight: " + weightvalue;
height.innerHTML="Height: " + heightvalue;
result.innerHTML="BMI: " + x;
level = document.querySelector("#good");
if(x < 19)
level.innerHTML="Too Low";
if(x >= 19 && x <=24)
level.innerHTML="Okay";
if(x > 24)
level.innerHTML="Too High";
}
</script>
</body>
</html>