-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
dietcalculator.html
145 lines (132 loc) Β· 4.5 KB
/
dietcalculator.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
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>diet calculator </title>
<style>
label {
display: block;
box-shadow: 0.1em 0.1em 0.2em #888;
margin: 1em;
border-radius: 1ex;
padding: 1ex 1em;
background-color: white;
color: black;
}
input[type=number] {
text-align: center;
border: none;
background-color: cyan;
color: black;
width: 10%;
}
input {
float: right;
}
span {
font-weight:bolder;
}
*{
background-color:#befca8;
font-size: 30px;
text-transform: capitalize;
}
</style>
</head>
<body>
<h1 align="center" style="font-size: 50px; color: black;">diet calculator</h1>
<label><b style="background-color: white;">Female:</b>
<input id="female" type="radio" name="gender" onchange="calsPerDay(),calsPerDay1(),calsPerDay2(),calsPerDay3()">
</label>
<label><b style="background-color: white;">Male:</b>
<input id="male" type="radio" name="gender" onchange="calsPerDay(),calsPerDay1(),calsPerDay2(),calsPerDay3()" checked>
</label>
<label><b style="background-color: white;">Age:</b>
<input id="age" type="number"minlength="1" style="border-radius: 30px;" oninput="calsPerDay(),calsPerDay1(),calsPerDay2(),calsPerDay3()" value="19">
(in years)
</label>
<label><b style="background-color: white;">Height:</b>
<input id="height" type="number" style="border-radius: 30px;" oninput="calsPerDay(),calsPerDay1(),calsPerDay2(),calsPerDay3()" value="70">
in inches (12 inches=1 foot)
</label>
<label><b style="background-color: white;">Weight:</b>
<input id="weight" type="number" style="border-radius: 30px;" oninput="calsPerDay(),calsPerDay1(),calsPerDay2(),calsPerDay3()" value="140">
in pounds
</label>
<label align ="center">
consume <span id="totalCals" style="color: green; background-color:white;"></span> gm of green vegetables a day
</label>
<script type="text/javascript">
function calsPerDay() {
function find(id) { return document.getElementById(id) }
var age = find("age").value
var height = find("height").value * 2.54
var weight = find("weight").value / 2.2
var result = 0
if (find("male").checked)
result = 1.47 + (1.75 * weight) + (1.0 * height - (1.75 * age))
else if (find("female").checked)
result = 1.09 + (1.56 * weight) + (1.84 * height - (1.67 * age))
find("totalCals").innerHTML = Math.round( result )
}
calsPerDay()
</script>
<!-- for pulses-->
<label align ="center">
consume <span id="totalCals1" style="color: brown; background-color:white;"></span> gm of pulses a day
</label>
<script type="text/javascript">
function calsPerDay1() {
function find(id) { return document.getElementById(id) }
var age = find("age").value
var height = find("height").value * 1.54
var weight = find("weight").value / 1.2
var result = 0
if (find("male").checked)
result = 0.47 + (1.75 * weight) + (1.0 * height - (1.75 * age))
else if (find("female").checked)
result = 0.09 + (0.56 * weight) + (1.04 * height - (1.07 * age))
find("totalCals1").innerHTML = Math.round( result )
}
calsPerDay1()
</script>
<!-- for water-->
<label align ="center">
consume <span id="totalCals2" style="color: blue; background-color:white;"></span> ml of water a day
</label>
<script type="text/javascript">
function calsPerDay2() {
function find(id) { return document.getElementById(id) }
var age = find("age").value
var height = find("height").value * 1.54
var weight = find("weight").value / 1.2
var result = 0
if (find("male").checked)
result = 3.47 + (8.75 * weight) + (4.0 * height - (1.75 * age))
else if (find("female").checked)
result = 2.09 + (6.56 * weight) + (3.04 * height - (1.07 * age))
find("totalCals2").innerHTML = Math.round( result )
}
calsPerDay2()
</script>
<!-- for dairy product-->
<label align ="center">
consume <span id="totalCals3" style="color: grey; background-color:white;"></span> gm of dairy product a day
</label>
<script type="text/javascript">
function calsPerDay3() {
function find(id) { return document.getElementById(id) }
var age = find("age").value
var height = find("height").value * 0.54
var weight = find("weight").value / 1.2
var result = 0
if (find("male").checked)
result = 0.07 + (1.75 * weight) + (1.0 * height - (1.75 * age))
else if (find("female").checked)
result = 0.09 + (0.56 * weight) + (1.04 * height - (1.07 * age))
find("totalCals3").innerHTML = Math.round( result )
}
calsPerDay3()
</script>
</body>
<footer>
<p align="center" style="color: black; padding: 150px;">© MyFitness 2021. All Rights Reserved ®</p>
</footer>