Tizenkettedik vizsga

This commit is contained in:
2024-12-07 20:29:31 +01:00
parent 06feade18d
commit 9ad420e866
5 changed files with 142 additions and 0 deletions

View File

@ -0,0 +1,40 @@
document.addEventListener("DOMContentLoaded", function () {
var inputs = Array.from(document.getElementsByTagName("input"));
for (i in inputs) {
inputs[i].addEventListener("change", function () {
var counter = 0
for (var i = 0; i < 3; i++) {
counter += Number(inputs[i].value);
}
document.getElementById("rowsum-1").innerText = counter;
counter = 0;
for (var i = 0; i < 3; i++) {
counter += Number(inputs[i + 3].value);
}
document.getElementById("rowsum-2").innerText = counter;
var ids = ["websum", "progsum", "adatbsum"];
for (var j = 0; j < 3; j++) {
counter = 0;
for (var i = 0; i < 6; i += 3) {
counter += Number(inputs[i + j].value);
}
document.getElementById(ids[j]).innerText = counter;
}
var prof1 = document.getElementById("rowsum-1").innerText
var prof2 = document.getElementById("rowsum-2").innerText
if (Number(prof1) >= 2 * Number(prof2)) {
document.getElementById("prof1").style.color = "red";
document.getElementById("prof2").style.color = "black";
} else if (Number(prof2) >= 2 * Number(prof1)) {
document.getElementById("prof2").style.color = "red";
document.getElementById("prof1").style.color = "black";
} else {
document.getElementById("prof2").style.color = "black";
document.getElementById("prof1").style.color = "black";
}
});
}
})