-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
63 lines (53 loc) · 1.95 KB
/
script.js
File metadata and controls
63 lines (53 loc) · 1.95 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const food = document.getElementById("food");
const portion = document.getElementById("portion");
const drink = document.getElementById("drink");
const temperature = document.getElementById("temperature");
const submitBtn = document.getElementById("submitBtn");
const result = document.getElementById("result");
const notification = document.getElementById("notification");
submitBtn.addEventListener("click", function () {
notification.className = "notification";
notification.style.opacity = "0";
if (
food.value === "" ||
portion.value === "" ||
drink.value === "" ||
temperature.value === ""
) {
notification.innerText = "Silakan lengkapi semua pilihan terlebih dahulu.";
notification.classList.add("error");
notification.style.opacity = "1";
notification.style.transform = "translateY(0)";
return;
}
result.style.display = "block";
result.innerHTML = `
<h3>Pilihan Kamu:</h3>
<p>Makanan: <b>${food.value}</b> - Porsi <b>${portion.value}</b></p>
<p>Minuman: <b>${drink.value}</b> - <b>${temperature.value}</b></p>
`;
document.body.style.background = "#e6fff2";
result.style.opacity = "0";
result.style.transform = "translateY(20px)";
setTimeout(() => {
result.style.transition = "0.5s";
result.style.opacity = "1";
result.style.transform = "translateY(0)";
}, 50);
food.disabled = true;
portion.disabled = true;
drink.disabled = true;
temperature.disabled = true;
submitBtn.disabled = true;
const selects = document.querySelectorAll("select");
selects.forEach(select => {
select.style.opacity = "0.6";
select.style.cursor = "not-allowed";
});
submitBtn.style.opacity = "0.6";
submitBtn.innerText = "Pesanan Terkunci";
notification.innerText = "Pesanan berhasil dikunci.";
notification.classList.add("success");
notification.style.opacity = "1";
notification.style.transform = "translateY(0)";
});