-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
29 lines (23 loc) · 830 Bytes
/
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
const divResult = document.getElementById("divResult");
const btnSummary = document.getElementById("btnSummary");
const btnDelete = document.getElementById("btnDelete");
const form = document.forms[1];
const discountCategory = {
estudiante: 0.80,
trainee: 0.50,
junior: 0.15,
};
btnSummary.addEventListener("click", (e) => {
e.preventDefault();
const amount = parseInt(form["amount"].value);
const category = form["category"].value;
const total = amount * 200;
const totalToPay = total - (total * discountCategory[category]);
document.getElementById("total").innerText = totalToPay;
divResult.style.display = "block";
});
btnDelete.addEventListener("click", (e) => {
e.preventDefault();
divResult.style.display = "none";
form.reset();
});