forked from sirineajbouni24/my-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript1.js
More file actions
63 lines (50 loc) · 1.77 KB
/
Copy pathscript1.js
File metadata and controls
63 lines (50 loc) · 1.77 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
document.addEventListener("DOMContentLoaded", function() {
var loginLink = document.getElementById("loginLink");
var loginForm = document.getElementById("loginForm");
loginLink.addEventListener("click", function(event) {
event.preventDefault(); // Prevent default link behavior
loginForm.style.display = "block";
});
});
/*
function login() {
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
// Check username and password (example, replace with your authentication logic)
if (username === "yourusername" && password === "yourpassword") {
alert("Login successful!");
// Perform further actions upon successful login
} else {
alert("Login failed. Please check your credentials.");
}
}
*/
var cart = [];
document.addEventListener("DOMContentLoaded", function() {
var cartItems = document.getElementById("cartItems");
if (cartItems) {
updateCartItems();
}
});
function addToCart(productName, price) {
cart.push({ productName, price });
updateCartItems();
}
function updateCartItems() {
var cartItems = document.getElementById("cartItems");
cartItems.innerHTML = "";
cart.forEach(function(item) {
var listItem = document.createElement("li");
listItem.textContent = item.productName + " - €" + item.price.toFixed(2);
cartItems.appendChild(listItem);
});
}
function login() {
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
if (username === "" || password === "") {
alert("Please fill in both username and password.");
} else {
alert("Login successful!");
}
}