-
Notifications
You must be signed in to change notification settings - Fork 0
/
adminproduct.html
65 lines (57 loc) · 1.82 KB
/
adminproduct.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reviews</title>
<style>
table {
width: 50%;
border-collapse: collapse;
margin: 20px auto;
}
th, td {
padding: 10px;
text-align: left;
border-bottom: 1px solid #ddd;
}
</style>
</head>
<body>
<h2 style="text-align:center">User Reviews</h2>
<table id="reviewsTable">
<thead>
<tr>
<th>Username</th>
<th>Review</th>
</tr>
</thead>
<tbody>
<!-- Reviews will be injected here by JavaScript -->
</tbody>
</table>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Sample data in localStorage (In practice, ensure this is already stored)
localStorage.setItem('reviews', JSON.stringify([
{"username": "sathwik", "reviewText": "I really like your service"}
]));
// Retrieve the reviews from local storage
const reviews = JSON.parse(localStorage.getItem('reviews')) || [];
// Reference to the table body where the reviews will be displayed
const reviewsTableBody = document.querySelector('#reviewsTable tbody');
// Generate table rows
reviews.forEach(review => {
const row = document.createElement('tr');
const usernameCell = document.createElement('td');
const reviewTextCell = document.createElement('td');
usernameCell.textContent = review.username;
reviewTextCell.textContent = review.reviewText;
row.appendChild(usernameCell);
row.appendChild(reviewTextCell);
reviewsTableBody.appendChild(row);
});
});
</script>
</body>
</html>