-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathda.js
More file actions
48 lines (39 loc) · 1.44 KB
/
Copy pathda.js
File metadata and controls
48 lines (39 loc) · 1.44 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
let weightSlider = document.getElementById("myWeight");
let weightOutput = document.getElementById("inputWeight");
let heightSlider = document.getElementById("myHeight");
let heightOutput = document.getElementById("inputHeight");
weightOutput.innerHTML = weightSlider.value;
heightOutput.innerHTML = heightSlider.value;
weightSlider.oninput = function() {
weightOutput.innerHTML = this.value;
}
heightSlider.oninput = function() {
heightOutput.innerHTML = this.value;
}
function showValWeight(newVal) {
weightSlider.value = newVal;
};
function showValHeight(newVal) {
heightSlider.value = newVal;
};
weightSlider.addEventListener("input", updateValueWeight);
heightSlider.addEventListener("input", updateValueHeight);
function updateValueWeight(e) {
weightOutput.value = e.srcElement.value;
}
function updateValueHeight(e) {
heightOutput.value = e.srcElement.value;
}
function calculateBmi() {
let weight = document.bmiForm.realweight.value;
let height = (document.bmiForm.realheight.value) / 100;
let realbmi = (weight) / Math.pow(height, 2);
let realbmiOutput = document.getElementById("yourbmi");
let messageOutput = document.getElementById("evaluationMessage");
let roundedBmi = realbmi.toFixed(1);
messageOutput.innerHTML = "";
realbmiOutput.innerHTML = " " + roundedBmi;
if (roundedBmi > 26) {
messageOutput.innerHTML = "<br>Start workout";
}
}