Kingston_Pendrive/Suli/12.b/Webprogramozás/Gyakorlat/Dolgozat/2023. 10. 10 - Testtömegindex számító alkalmazás/script.js

26 lines
846 B
JavaScript
Raw Normal View History

2024-11-19 18:04:02 +00:00
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"
}
})