-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
93 lines (76 loc) · 3.36 KB
/
Copy pathindex.html
File metadata and controls
93 lines (76 loc) · 3.36 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
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html>
<head>
<title>Password Manager</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lato&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div class="container">
<form id="passwordForm">
<h1 class="heading">Password Manager</h1>
<!-- <span> -->
<label for="website">Website:</label>
<input type="text" id="website" name="website" required>
<!-- </span> -->
<!-- <span> -->
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<!-- </span> -->
<!-- <span> -->
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<!-- </span> -->
<button type="submit">Save Password</button>
</form>
<div id="passwordList">
<!-- Passwords will be dynamically added here -->
</div>
</div>
<script>
// Get the form element
const passwordForm = document.getElementById('passwordForm');
// Add event listener to the form submit event
passwordForm.addEventListener('submit', function(event) {
event.preventDefault(); // Prevent form submission
// Get the input values
const websiteInput = document.getElementById('website');
const usernameInput = document.getElementById('username');
const passwordInput = document.getElementById('password');
// Create a new password object
const password = {
website: websiteInput.value,
username: usernameInput.value,
password: passwordInput.value
};
// Clear the input fields
websiteInput.value = '';
usernameInput.value = '';
passwordInput.value = '';
// Call a function to save the password
savePassword(password);
});
// Function to save the password
function savePassword(password) {
// Create a new password element
const passwordElement = document.createElement('div');
passwordElement.classList.add('password');
// Create HTML content for the password element
passwordElement.innerHTML = `
<p><strong>Website:</strong> ${password.website}</p>
<p><strong>Username:</strong> ${password.username}</p>
<p><strong>Password:</strong> ${password.password}</p>
`;
const gap = document.createElement('br');
passwordElement.appendChild(gap);
const divider = document.createElement('hr');
passwordElement.appendChild(divider);
// Append the password element to the password list
const passwordList = document.getElementById('passwordList');
passwordList.appendChild(passwordElement);
}
</script>
</body>
</html>