-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
30 lines (25 loc) · 1.21 KB
/
script.js
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
var hamburguer = document.querySelector(".hamburguer");
hamburguer.addEventListener("click", function() {
document.querySelector(".container").classList.toggle("show-menu");
});
document.querySelector("#qtde").addEventListener("change", atualizarPreco)
document.querySelector("#js").addEventListener("change", atualizarPreco)
document.querySelector("#layout-sim").addEventListener("change", atualizarPreco)
document.querySelector("#layout-nao").addEventListener("change", atualizarPreco)
document.querySelector("#prazo").addEventListener("change", function() {
const prazo = document.querySelector("#prazo").value
document.querySelector("label[for=prazo]").innerHTML = `Prazo: ${prazo} semanas`
atualizarPreco()
})
function atualizarPreco() {
const qtde = document.querySelector("#qtde").value
const temJS = document.querySelector("#js").checked
const incluiLayout = document.querySelector("#layout-sim").checked
const prazo = document.querySelector("#prazo").value
let preco = qtde * 100;
if (temJS) preco *= 1.1
if (incluiLayout) preco += 500
let taxaUrgencia = 1 - prazo * 0.1;
preco *= 1 + taxaUrgencia
document.querySelector("#preco").innerHTML = `R$ ${preco.toFixed(2)}`
}