<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ร้านขาย Nitro</title>
<link rel
="stylesheet" href
="styles.css"> </head>
<body>
<header>
<h1>ร้านขาย Nitro</h1>
<nav>
<a href="index.html">หน้าแรก</a>
<a href="login.html">เข้าสู่ระบบ</a>
<a href="cart.html">รถเข็น</a>
</nav>
</header>
<section class="products">
<h2>รายการ Nitro</h2>
<div class="product">
<img src="nitro1.png" alt="Nitro Basic">
<h3>Nitro Basic</h3>
<p>ราคา: 100 บาท</p>
<button onclick="addToCart('Nitro Basic', 100)">เพิ่มลงรถเข็น</button>
</div>
<div class="product">
<img src="nitro2.png" alt="Nitro Boost">
<h3>Nitro Boost</h3>
<p>ราคา: 200 บาท</p>
<button onclick="addToCart('Nitro Boost', 200)">เพิ่มลงรถเข็น</button>
</div>
</section>
<footer>
<p>ร้านขาย Nitro © 2025</p>
</footer>
<script src="script.js"></script>
</body>
</html>
body {
font-family: Arial, sans-serif;
background-color: #dff0ff;
text-align: center;
}
background-color: #0099ff;
color: white;
padding: 15px;
}
nav a {
color: white;
text-decoration: none;
margin: 0 15px;
}
.products {
display: flex;
justify-content: center;
margin-top: 20px;
}
.product {
background: white;
padding: 15px;
margin: 10px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
button {
background: #007bff;
color: white;
border: none;
padding: 10px;
cursor: pointer;
}
button:hover {
background: #0056b3;
}
<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>รถเข็น</title>
<link rel
="stylesheet" href
="styles.css"> </head>
<body>
<header>
<h1>รถเข็นของฉัน</h1>
<nav>
<a href="index.html">หน้าแรก</a>
<a href="login.html">เข้าสู่ระบบ</a>
</nav>
</header>
<section>
<h2>สินค้าที่เลือก</h2>
<ul id="cart-list"></ul>
<p>ยอดรวม: <span id="total-price">0</span> บาท</p>
<button onclick="checkout()">ชำระเงิน</button>
</section>
<script src="script.js"></script>
</body>
</html>
<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>เข้าสู่ระบบ</title>
<link rel
="stylesheet" href
="styles.css"> </head>
<body>
<header>
<h1>เข้าสู่ระบบ</h1>
<nav>
<a href="index.html">หน้าแรก</a>
</nav>
</header>
<section>
<form id="login-form">
<label for="username">ชื่อผู้ใช้:</label>
<input type="text" id="username" required>
<label for="password">รหัสผ่าน:</label>
<input type="password" id="password" required>
<button type="submit">เข้าสู่ระบบ</button>
</form>
</section>
<script>
document.getElementById("login-form").addEventListener("submit", function(event) {
event.preventDefault();
alert("เข้าสู่ระบบสำเร็จ!");
});
</script>
</body>
</html>
let cart = [];
function addToCart(productName, price) {
cart.push({ name: productName, price: price });
localStorage.setItem("cart", JSON.stringify(cart));
alert(productName + " ถูกเพิ่มลงในรถเข็น!");
}
function loadCart() {
let cartList = document.getElementById("cart-list");
let totalPrice = document.getElementById("total-price");
cart = JSON.parse(localStorage.getItem("cart")) || [];
cartList.innerHTML = "";
let sum = 0;
cart.forEach((item, index) => {
let li = document.createElement("li");
li.textContent = `${item.name} - ${item.price} บาท`;
cartList.appendChild(li);
sum += item.price;
});
totalPrice.textContent = sum;
}
function checkout() {
alert("ไปหน้าชำระเงิน!");
}
if (document.getElementById("cart-list")) {
loadCart();
}