-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabc.html
164 lines (150 loc) · 5.33 KB
/
abc.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body>
<header>
<h1 style="color: aliceblue;">BidWave</h1>
<div>
<ul id="navbar">
<li><a class="active" href="index.html">Home</a></li>
<li><a href="shop.html">Shop</a></li>
<li><a href="about.html">About</a></li>
<li><a href="contact.html"> contact</a></li>
<li><a href="cart.html">Cart</a></li>
</ul>
</div>
<div class="nav-search">
<select class="search-select">
<option>All</option>
<option>Mobiles</option>
<option>Cars</option>
</select>
<input placeholder="Search Product" class="search-input" id="searchInput">
<div class="search-icon">
<i class="fa-solid fa-magnifying-glass"></i>
</div>
</div>
</header>
<section id="hero">
<h4>Trade-in-offer</h4>
<h1 style="font-size:40px;"> Super value deals</h1>
<h1 style="font-size:30px;"> On all products</h1>
<button>Shop Now</button>
</section>
<section id="product1" class="section-p1">
<h1 style="font-size:50px;">Featured Products</h1>
<p style="font-size:30px;">Collections</p>
<div class="pro-container" id="productContainer">
<!-- Products will be dynamically inserted here by JavaScript -->
</div>
</section>
<script>
// Define the array of products
const products = [
{
name: "Astronaut T-shirts",
image: "f1.jpg",
brand: "adidas",
rating: 5,
price: 78,
},
{
name: "Floral T-shirts",
image: "f5.jpg",
brand: "adidas",
rating: 5,
price: 88,
},
{
name: "Classic T-shirts",
image: "f6.jpg",
brand: "adidas",
rating: 5,
price: 49,
},
{
name: "Beign Trouser",
image: "f7.jpg",
brand: "adidas",
rating: 5,
price: 52,
},
{
name: "Beach T-shirts",
image: "f2.jpg",
brand: "adidas",
rating: 5,
price: 68,
},
{
name: "Roseprint T-shirts",
image: "f3.jpg",
brand: "adidas",
rating: 5,
price: 67,
},
{
name: "Cherryblossom T-shirts",
image: "f4.jpg",
brand: "adidas",
rating: 5,
price: 83,
},
// Add more products similarly
];
// Function to generate product HTML (same as before)
function generateProductHTML(product) {
return `
<div class="pro">
<img src="${product.image}" alt="">
<div class="des">
<span>${product.brand}</span>
<h5>${product.name}</h5>
<div class="star">
${'<i class="fas fa-star"></i>'.repeat(product.rating)}
</div>
<h4>$${product.price}</h4>
</div>
</div>
`;
}
// Function to display products (same as before)
function displayProducts() {
const productContainer = document.getElementById("productContainer");
products.forEach((product) => {
const productHTML = generateProductHTML(product);
productContainer.innerHTML += productHTML;
});
}
// Function to filter and display products based on the search query
function filterProducts(query) {
const productContainer = document.getElementById("productContainer");
productContainer.innerHTML = ''; // Clear the existing product listings
products.forEach((product) => {
// Check if the product name or brand contains the search query
if (
product.name.toLowerCase().includes(query.toLowerCase()) ||
product.brand.toLowerCase().includes(query.toLowerCase())
) {
const productHTML = generateProductHTML(product);
productContainer.innerHTML += productHTML;
}
});
// If no products match the search query, you can display a message or handle it as desired.
}
// Handle search input changes
const searchInput = document.getElementById("searchInput");
searchInput.addEventListener("input", () => {
const searchQuery = searchInput.value;
filterProducts(searchQuery);
});
// Initial display of products
displayProducts();
</script>
</body>
</html>