-
Notifications
You must be signed in to change notification settings - Fork 0
/
UID_Proj_Pet_Accessories_2.html
271 lines (242 loc) · 9.53 KB
/
UID_Proj_Pet_Accessories_2.html
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<!DOCTYPE HTML>
<html>
<head>
<link rel="icon" href="logo.jpeg" >
<meta name="viewport" content="width=device-width">
<title>PawStop | Pet Accessories Shop </title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f2f2f2;
}
header {
background-color: #333;
color: #fff;
padding: 10px 0;
text-align: center;
}
nav {
background-color: #444;
color: #fff;
overflow: hidden;
}
nav a {
float: left;
display: block;
color: #fff;
text-align: center;
padding: 14px 20px;
text-decoration: none;
}
nav a:hover {
background-color: #ddd;
color: #000;
}
.menu a {
color: #fff;
text-decoration: none;
margin-right: 10px;
}
.container {
display: grid;
grid-template-columns: 3fr 1fr;
gap: 20px;
margin: 20px;
}
.products {
display: flex;
gap: 20px;
padding: 20px;
flex-wrap: wrap;
background-color: #fff;
border: 1px solid #ccc;
}
.product {
flex: 1;
border: 1px solid #ccc;
padding: 20px;
margin-bottom: 20px;
}
.product button {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}
.product button:hover {
background-color: #45a049;
}
.cart {
padding: 20px;
background-color: #fff;
border: 1px solid #ccc;
}
.cart h2 {
margin-top: 0;
}
.cart-item {
display: flex;
justify-content: space-between;
margin-bottom: 10px;
}
.cart-item button {
background-color: #f44336;
color: white;
padding: 5px 10px;
border: none;
border-radius: 4px;
cursor: pointer;
}
.cart-item button:hover {
background-color: #d32f2f;
}
.pay-now {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
width: 100%;
}
.pay-now:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<header>
<h1>Pet Accessories Store</h1>
</header>
<nav>
<a href="main_page.html">Home</a>
<a href="joinus.html">About Us</a>
<a href="adopt.html">Adopt a Pet</a>
<a href="UID_Proj_GiveUpPet_2.html">Give Up a Pet</a>
<a href="Great.html">Training Programs</a>
<a href="Peteventandactivities.html">Events & Activities</a>
<a href="UID_Proj_Pet_Food_2.html">Buy Food</a>
<a href="UID_Proj_Pet_Accessories_2.html">Buy Accessories</a>
<a href="vet-entry.html">Call a Vet</a>
<a href="signin.html">Sign In</a>
<a href="signup.html">Sign Up</a>
</nav>
<h2 align="center">Accessories Store</h2>
<div class="container">
<div class="products">
<div class="product">
<img src="w9pooperscooper.jpeg" width="350" height="300"/>
<h2>W9:Pooper Scooper</h2>
<p>Price: $40</p>
<button onclick="addToCart('W9:Pooper Scooper', 40)">Add to Cart</button>
</div>
<div class="product">
<img src="amazonstainlesssteelpetbowl.jpeg" width="350" height="300"/>
<h2>Amazon:Stainless Steel Pet Bowl</h2>
<p>Price: $20</p>
<button onclick="addToCart('Amazon:Stainless Steel Pet Bowl', 20)">Add to Cart</button>
</div>
<div class="product">
<img src="amazonpetbed.jpeg" width="350" height="250" />
<h2>Amazon:Large Pet Bed</h2>
<p>Price: $45</p>
<button onclick="addToCart('Amazon:Large Pet Bed', 45)">Add to Cart</button>
</div>
<div class="product">
<img src="amazonshampoo.jpeg" width="300" height="200" />
<h2>Amazon:Pet Shampoo</h2>
<p>Price: $25</p>
<button onclick="addToCart('Amazon:Pet Shampoo', 25)">Add to Cart</button>
</div>
<div class="product">
<img src="amazonchewtoy.jpeg" width="300" height="300" />
<h2>Amazon:Non-Toxic Chew Toy </h2>
<p>Price: $30</p>
<button onclick="addToCart('Amazon:Chew Toy', 30)">Add to Cart</button>
</div>
<div class="product">
<img src="emilypetbrush.jpeg" width="300" height="300" />
<h2>Emily:Detangling Brush</h2>
<p>Price: $40</p>
<button onclick="addToCart('Emily:Detangling Brush', 40)">Add to Cart</button>
</div>
<div class="product">
<img src="polypetsleash.jpeg" width="300" height="300" />
<h2>PolyPets:Leash</h2>
<p>Price: $45</p>
<button onclick="addToCart('PolyPets:Leash', 45)">Add to Cart</button>
</div>
<!-- Add more products as required -->
</div>
<div class="cart" >
<h2>Shopping Cart</h2>
<div id="cartItems"></div>
<p id="totalPrice">Total: $0</p>
<button class="pay-now" onclick="payNow()">Pay Now</button>
</div>
</div>
<script>
let cart = [];
function addToCart(itemName, itemPrice) {
cart.push({ name: itemName, price: itemPrice });
updateCart();
}
function removeFromCart(index) {
cart.splice(index, 1);
updateCart();
}
function updateCart() {
const cartItems = document.getElementById('cartItems');
cartItems.innerHTML = '';
let total = 0;
cart.forEach((item, index) => {
total += item.price;
cartItems.innerHTML += `
<div class="cart-item">
<span>${item.name}: $${item.price}</span>
<button onclick="removeFromCart(${index})">Remove</button>
</div>
`;
});
document.getElementById('totalPrice').textContent = `Total: $${total}`;
}
function payNow() {
if (cart.length === 0) {
alert('Your cart is empty!');
} else {
alert('Proceeding to payment');
// Here you can add your payment logic
}
}
</script>
</body>
</html>
<!--
HTML Structure:
The HTML document starts with the usual doctype declaration and sets the language to English.
Inside the <head> section, we specify the character set, viewport settings, and the title of the webpage.
The <body> contains the main content of the webpage.
Header:
We have a <header> element containing the title "Pet Accessories Shop". This serves as the title of the webpage.
Container:
The .container class sets a maximum width for the content and centers it horizontally on the page.
Product Listings:
Each product is represented by a <div> element with the class "product".
Inside each product div, we have:
A heading (<h2>) for the product name.
A paragraph (<p>) for the product price.
An "Add to Cart" button (<button>) with an onclick attribute that calls the addToCart() function with the product name and price as arguments.
Cart Button:
We have a "View Cart" button positioned fixed at the bottom right corner of the page. This button is styled with the .cart class.
Clicking this button triggers the viewCart() function.
JavaScript:
We start by declaring an empty array cart to store the items added to the cart.
The addToCart() function is called when the "Add to Cart" button for a product is clicked. It takes the product name and price as arguments, creates an object representing the item, and pushes it into the cart array. It then displays an alert confirming the addition of the item to the cart.
The viewCart() function is called when the "View Cart" button is clicked. It iterates over the items in the cart array, calculates the total price, and constructs a string displaying the items and their prices. This string is then displayed in an alert dialog.
Styling:
Basic CSS is used to style the header, products, buttons, and the container.
-->