-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path06_ContactList.html
More file actions
83 lines (73 loc) · 2.41 KB
/
06_ContactList.html
File metadata and controls
83 lines (73 loc) · 2.41 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Phonebook</title>
<!-- Include Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
h1 {
text-align: center;
color: #007bff;
}
.contact {
width: 80%;
margin: 20px auto;
background-color: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
border-radius: 10px;
}
.search-box {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
.result-item {
padding: 10px;
border-top: 1px solid #ccc;
}
.result-item strong {
font-weight: bold;
}
</style>
</head>
<body>
<h1>Phonebook</h1>
<div class="contact container">
<input type="text" class="search-box form-control" placeholder="Search by name...">
<div id="results"></div>
</div>
<script>
const contacts = {
"John Smith": "123-456-7890",
"Alice Johnson": "987-654-3210",
"Robert Brown": "555-123-4567",
"Emily Davis": "111-222-3333",
// Add more contact names and numbers here
};
const searchBox = document.querySelector('.search-box');
const results = document.getElementById('results');
searchBox.addEventListener('input', () => {
const query = searchBox.value.toLowerCase();
results.innerHTML = "";
for (const contact in contacts) {
if (contact.toLowerCase().includes(query)) {
const details = contacts[contact];
const resultItem = document.createElement('div');
resultItem.classList.add('result-item');
resultItem.innerHTML = `<strong>${contact}:</strong> ${details}`;
results.appendChild(resultItem);
}
}
});
</script>
<!-- Include Bootstrap JS and jQuery -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>