-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeliver26.js
More file actions
50 lines (41 loc) · 1.48 KB
/
deliver26.js
File metadata and controls
50 lines (41 loc) · 1.48 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
// Simulated order data
const orders = [
];
// Function to populate the order list
function populateOrderList() {
const ordersElement = document.getElementById("orders");
ordersElement.innerHTML = "";
orders.forEach(order => {
const listItem = document.createElement("li");
listItem.innerHTML = `<strong>${order.name}</strong>: ${order.youraddress} <strong>To</strong> ${order.deliveryaddress} : ${order.fooditem}`;
ordersElement.appendChild(listItem);
});
}
// Function to handle the form submission
function handleFormSubmission(event) {
event.preventDefault();
const nameInput = document.getElementById("name");
const fooditemin = document.getElementById("fooditem");
const deliveryadd = document.getElementById("deliveryaddress");
const youradd = document.getElementById("youraddress");
const contact = document.getElementById("contact");
const order = {
name: nameInput.value,
fooditem: fooditemin.value,
deliveryaddress: deliveryadd.value,
youraddress: youradd.value,
contact:contact.value,
};
orders.push(order);
populateOrderList();
// Clear the form inputs
nameInput.value = "";
deliveryadd.value = "";
fooditemin.value = "";
youradd.value = "";
contact.value = "";
}
// Event listener for form submission
document.getElementById("delivery-form").addEventListener("submit", handleFormSubmission);
// Populate the initial order list
populateOrderList();