-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
35 lines (28 loc) · 828 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
30
31
32
33
34
35
/*/ define
const selectElement = document.getElementById('coffee_item');
const cartItems = document.getElementById('cart_items');
// Function to update cart
function updateCart() {
const selectedItem = selectElement.value;
if (selectedItem) {
cartItems.textContent = selectedItem;
} else {
cartItems.textContent = 'None';
}
}
Add an event listener to the select element
selectElement.addEventListener('change', updateCart);
*/
const selectElement = document.getElementById('coffee_item');
const cartItems = document.getElementById('cart_items');
function updatecart() {
const selectedItem = selectElement.value;
if (selectedItem.length>0) {
cartItems = selectedItem;
console.log(cartItems)
}else{
cartItems = "None";
}
}
typeof selectElement
finwl