-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScript.js
More file actions
83 lines (73 loc) · 2.55 KB
/
Copy pathScript.js
File metadata and controls
83 lines (73 loc) · 2.55 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
// Array to store contact details
let contacts = [];
// Function to add a new contact
function addContact() {
// Get values from input fields
let name = document.getElementById("name").value;
let phone = document.getElementById("phone").value;
let email = document.getElementById("email").value;
let address = document.getElementById("address").value;
let age = document.getElementById("age").value;
let gender = document.getElementById("gender").value;
let dob = document.getElementById("dob").value;
// Get uploaded files
let profilePicture = document.getElementById("profilePicture").files[0];
let resume = document.getElementById("resume").files[0];
// Validate inputs
if (!name || !phone || !email || !address || !age || !gender || !dob || !profilePicture || !resume) {
alert("Please fill out all fields.");
return;
}
// Create a contact object
let contact = {
name,
phone,
email,
address,
age,
gender,
dob,
profilePicture: profilePicture.name,
resume: resume.name
};
// Add contact to the array
contacts.push(contact);
// Clear input fields
document.getElementById("name").value = "";
document.getElementById("phone").value = "";
document.getElementById("email").value = "";
document.getElementById("address").value = "";
document.getElementById("age").value = "";
document.getElementById("gender").value = "";
document.getElementById("dob").value = "";
document.getElementById("profilePicture").value = "";
document.getElementById("resume").value = "";
// Display updated contact list
displayContacts();
}
// Function to display contacts
function displayContacts() {
let contactList = document.getElementById("contactList");
contactList.innerHTML = "";
contacts.forEach((contact, index) => {
let li = document.createElement("li");
li.innerHTML = `
<span>Name: ${contact.name}</span>
<span>Phone: ${contact.phone}</span>
<span>Email: ${contact.email}</span>
<span>Address: ${contact.address}</span>
<span>Age: ${contact.age}</span>
<span>Gender: ${contact.gender}</span>
<span>DOB: ${contact.dob}</span>
<span>Profile Picture: ${contact.profilePicture}</span>
<span>Resume: ${contact.resume}</span>
<span class="delete-btn" onclick="deleteContact(${index})">Delete</span>
`;
contactList.appendChild(li);
});
}
// Function to delete a contact
function deleteContact(index) {
contacts.splice(index, 1);
displayContacts();
}