-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfood.js
More file actions
123 lines (93 loc) · 3.3 KB
/
food.js
File metadata and controls
123 lines (93 loc) · 3.3 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// const foodInput = document.getElementById("foodInput");
// const drinkInput = document.getElementById("drinkInput");
// const addItemsButton = document.getElementById("addItemsButton");
// const Total = document.getElementById("Total");
// function Enter() {
// var foodValue = foodInput.value;
// const drinkValue = drinkInput.value;
// var Total = foodValue + drinkValue;
// for (var key in foodItems) {
// if (Object.hasOwnProperty.call(foodItems, key)) {
// const Total = foodItems[key];
// document.write(Total)
// }
// }
function Enter(){
const foodSelect = document.getElementById("foodSelect");
const selectedFood = foodSelect.value;
const drinkSelect = document.getElementById("drinkSelect");
const selectedDrink = drinkSelect.value;
// Arrays for food and drinks items
const foodItems = {
Smallchops: 37,
ChickenChips: 23,
JollofRiceBeef: 70,
SandWiches: 66,
Sharwama: 85,
HotDog: 40,
FrenchFries: 50,
BUGGER: 25,
PIZZA: 90
};
const drinkItems = {
FruitJuice: 75,
Coffee: 65,
HotTea: 95,
Americano: 75,
Latte: 45,
OldFashioned: 25,
WhiskeySour: 95,
TableWater: 50,
Vodkasoda: 45
};
const foodPrice = foodItems[selectedFood] || 0;
const drinkPrice = drinkItems[selectedDrink] || 0;
const totalAmount = foodPrice + drinkPrice;
// display the Total AMount
const totalAmountDisplay = document.getElementById("totalAmountDisplay");
totalAmountDisplay.textContent = `Total Amount cost: $${totalAmount}`;
// document.addEventListener("DOMContentLoaded", function (){
// const foodInput = document.getElementById("foodInput");
// const drinkInput = document.getElementById("drinkInput");
// const addItemsButton = document.getElementById("addItemsButton");
// const totalAmountDisplay = document.getElementById("totalAmountDisplay");
// addItemsButton.addEventListener("click", function () {
// const selectedFood = foodSelect.value;
// const selectedDrink = drinkSelect.value;
// const selectedFoodAmount = parseFloat(foodItems[selectedFood]) || 0;
// const selectedDrinkAmount = parseFloat(selectedDrink[drinkItems]) || 0;
// const totalAmount = selectedFoodAmount + selectedDrinkAmount;
// totalAmountDisplay.textcontext = "$" + totalAmount.toFixed(2);
// });
// });
}
// }
// if (foodValue.trim() !== "HotDog") {
// foodItems.push(foodValue);
// }
// if (drinkValue.trim() !== "Tablewater") {
// drinkItems.push(drinkValue);
// }
// updateTotal();
// clearInputs();
// Function to update the list of items in the UI
// function updateTotal() {
// Total.innerHTML = "";
// foodItems.forEach((food) => {
// const foodItem = document.createElement("li");
// foodItem.textContent = `Food: ${food}`;
// itemList.appendChild(foodItem);
// });
// drinkItems.forEach((drink) => {
// const drinkItem = document.createElement("li");
// drinkItem.textContent = `Drink: ${drink}`;
// itemList.appendChild(drinkItem);
// });
// }
// // Function to clear input fields
// function clearInputs() {
// foodInput.value = "";
// drinkInput.value = "";
// }
// // Attach the addItem function to the button click event
// addItemButton.addEventListener("click", addItem);