26 lines
846 B
JavaScript
26 lines
846 B
JavaScript
|
const testsuly = document.getElementById("testsuly")
|
||
|
const magassag = document.getElementById("magassag")
|
||
|
const index = document.getElementById("testomeg")
|
||
|
const sulytobblet = document.getElementById("sulytobblet")
|
||
|
const button = document.querySelector("button")
|
||
|
|
||
|
button.addEventListener("click", ()=>{
|
||
|
console.log(sulytobblet);
|
||
|
let magassag_m = magassag.value / 100
|
||
|
let eredmeny = Math.round(testsuly.value / Math.pow(magassag_m, 2) * 100) / 100
|
||
|
index.value = eredmeny
|
||
|
sulytobblet.value = Math.round(testsuly.value - 25 * Math.pow((magassag.value / 100), 2) * 100) / 100
|
||
|
if (eredmeny < 18)
|
||
|
{
|
||
|
index.style.backgroundColor = "yellow"
|
||
|
}
|
||
|
|
||
|
else if (eredmeny > 18 && eredmeny <= 25)
|
||
|
{
|
||
|
index.style.backgroundColor = "green"
|
||
|
}
|
||
|
|
||
|
else{
|
||
|
index.style.backgroundColor = "red"
|
||
|
}
|
||
|
})
|