-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript2.js
More file actions
35 lines (30 loc) · 1.26 KB
/
script2.js
File metadata and controls
35 lines (30 loc) · 1.26 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
document.addEventListener("DOMContentLoaded", function () {
updatePrice();
document.getElementById("paymentMethodInput").value = document.getElementById("paymentMethod").value;
});
function updatePrice() {
const basePrice = 339;
const quantity = document.getElementById("quantity").value;
const totalPrice = basePrice * quantity;
document.getElementById("totalPrice").innerHTML = `₹${totalPrice}.00`;
document.getElementById("totalPriceInput").value = totalPrice;
}
function togglePaymentFields() {
const paymentMethod = document.getElementById("paymentMethod").value;
document.getElementById("paymentMethodInput").value = paymentMethod;
const deliveryFields = document.getElementById("deliveryFields");
if (paymentMethod === "Pay Online") {
deliveryFields.style.display = "none";
} else {
deliveryFields.style.display = "block";
}
}
function showCelebration(event) {
event.preventDefault();
if (confirm("Are you sure you want to place this order? A confirmation email will be sent.")) {
document.getElementById("celebration").style.display = "block";
setTimeout(() => {
document.getElementById("orderForm").submit();
}, 1000);
}
}