-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusersList.html
94 lines (85 loc) · 3.03 KB
/
usersList.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
<!DOCTYPE html>
<html>
<head>
<title>View Users</title>
<!-- Add Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
h1 {
text-align: center;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<div class="container">
<h1 class="text-center">View Users</h1>
<table id="userTable" class="table table-bordered table-hover mt-4">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Role</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<!-- Table rows will be dynamically populated using JavaScript -->
</tbody>
</table>
</div>
<script>
// Dummy data for demonstration purposes
var users = [
{ id: 1, name: "John Doe", email: "[email protected]", role: "Admin", status: "Active" },
{ id: 2, name: "Jane Smith", email: "[email protected]", role: "User", status: "Active" },
{ id: 3, name: "David Brown", email: "[email protected]", role: "User", status: "Inactive" }
];
// Function to populate table with user data
function populateTable() {
var tableBody = document.getElementById("userTable").getElementsByTagName("tbody")[0];
// Clear existing table rows
tableBody.innerHTML = "";
// Loop through users data and add rows to table
for (var i = 0; i < users.length; i++) {
var row = document.createElement("tr");
var idCell = document.createElement("td");
idCell.textContent = users[i].id;
row.appendChild(idCell);
var nameCell = document.createElement("td");
nameCell.textContent = users[i].name;
row.appendChild(nameCell);
var emailCell = document.createElement("td");
emailCell.textContent = users[i].email;
row.appendChild(emailCell);
var roleCell = document.createElement("td");
roleCell.textContent = users[i].role;
row.appendChild(roleCell);
var statusCell = document.createElement("td");
statusCell.textContent = users[i].status;
row.appendChild(statusCell);
tableBody.appendChild(row);
}
}
// Call the populateTable function to initially populate the table
populateTable();
</script>
</body>
</html>