-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode-together0.js
More file actions
48 lines (38 loc) · 1.62 KB
/
code-together0.js
File metadata and controls
48 lines (38 loc) · 1.62 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
//Change Form submit type
document.getElementById('form0').addEventListener('submit', function(evento){
evento.preventDefault();
evento.stopPropagation();
});
function MediaCalc() { //Calcular média
let a = parseInt(document.getElementById("nota01").value);
let b = parseInt(document.getElementById("nota02").value);
let c = parseInt(document.getElementById("nota03").value);
let d = parseInt(document.getElementById("nota04").value);
let media = (a + b + c + d) / 4;
document.getElementById("resultado").value = media;
//Fim do Cálculo de Média
//Alterar Style do Resultado e do State com base na nota
if(media >= 7){
document.getElementById('resultado').style.color = "greenyellow"
} else if (media >= 5) {
document.getElementById('resultado').style.color = "yellow"
} else {
document.getElementById('resultado').style.color = "red"
}
if(media >= 7){
document.getElementById('state').style.backgroundColor = "green"
document.getElementById('state').style.color = "white"
document.getElementById('state').value = "Aprovado"
} else if (media >= 5) {
document.getElementById('state').style.backgroundColor = "yellow"
document.getElementById('state').style.color = "black"
document.getElementById('state').value = "Recuperação"
} else {
document.getElementById('state').style.backgroundColor = "red"
document.getElementById('state').style.color = "white"
document.getElementById('state').value = "Reprovado"
}
//Console.log
console.log(media);
console.log(a + b + c + d)
}