-
Notifications
You must be signed in to change notification settings - Fork 0
/
bmi.js
113 lines (96 loc) · 3.28 KB
/
bmi.js
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
// Get the modal
var modal = document.getElementById('myModal');
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
document.getElementById("age1").value = "";
document.getElementById("hei1").value = "";
document.getElementById("wei1").value = "";
document.getElementById("gen1").checked = false;
document.getElementById("gen2").checked = false;
document.getElementById("p1").innerHTML = "";
document.getElementById("p2").innerHTML = "";
document.getElementById("p3").innerHTML = "";
document.getElementById("p4").innerHTML = "";
document.getElementById("output").innerHTML = "";
document.getElementById("comment").innerHTML = "";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
function evalute()
{
var m=document.getElementById("gen1");
var f=document.getElementById("gen2");
if (m.checked == false && f.checked == false)
{
document.getElementById("p2").innerHTML="Plz.. select gender";
return false;
}
var h=document.getElementById("hei1").value;
var w=document.getElementById("wei1").value;
h=h/100;
var bmi=(w*1)/(h*h);
bmi=parseInt(bmi);
var output = bmi.toPrecision(4);
document.getElementById("output").innerText=(bmi);
if (output < 18.5){
document.getElementById("comment").style='color:#21618C;';
document.getElementById("comment").innerText = "This means you are Underweight";
}
else if (output >= 18.5 && output <= 25){
document.getElementById("comment").style='color:#52BE80;';
document.getElementById("comment").innerText = "This means you are Normal";
}
else if (output >= 25 && output <= 30) {
document.getElementById("comment").style='color:#E59866;';
document.getElementById("comment").innerText = "This means you are Obese";
}
else if (output > 30){
document.getElementById("comment").style='color:#D35400;';
document.getElementById("comment").innerText = "This means you are Overweight";
}
return true;
}
function age_validate(){
var a=document.getElementById("age1");
if (a.value==""){
document.getElementById("p1").innerText="Plz.. fill age";
}
}
//function gen_validate(){}
function height_validate(){
var h=document.getElementById("hei1").value;
if (h==""){
document.getElementById("p3").innerText="Plz.. fill height";
}
}
function weight_validate(){
var w=document.getElementById("wei1").value;
if (w==""){
document.getElementById("p4").innerText="Plz.. fill weight";
}
}
function validate_age(){
document.getElementById('p1').innerHTML="";
//document.getElementById('age1').style='none';
}
function validate_height(){
document.getElementById('p3').innerHTML="";
//document.getElementById('hei1').style='none';
}
function validate_weight(){
document.getElementById('p4').innerHTML="";
//document.getElementById('wei1').style='none';
}