-
Notifications
You must be signed in to change notification settings - Fork 0
/
placemntholder.js
48 lines (38 loc) · 1.38 KB
/
placemntholder.js
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
const form = document.getElementById('myForm');
const result = document.getElementById('result');
form.addEventListener('submit', (event) => {
event.preventDefault();
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const message = document.getElementById('message').value;
const phoneNumber=document.getElementById('phoneNumber').value;
localStorage.setItem('name', name);
localStorage.setItem('email', email);
localStorage.setItem('phoneNumber',phoneNumber);
localStorage.setItem('message', message);
result.innerHTML = `
<h2>Thank You</h2>
<p>Name: ${name}</p>
<p>Email: ${email}</p>
<p>phoneNumber: ${phoneNumber}</p>
<p>Message: ${message}</p>
`;
form.reset();
result.style.display = 'block';
});
window.addEventListener('DOMContentLoaded', () => {
const name = localStorage.getItem('name');
const email = localStorage.getItem('email');
const phoneNumber=localStorage.getItem('phoneNumber');
const YourDemand = localStorage.getItem('Your Demand:');
if (name && email && message) {
result.innerHTML = `
<h2>Stored Contact Information</h2>
<p>Name: ${name}</p>
<p>Email: ${email}</p>
<p>phoneNumber: ${phoneNumber}</p>
<p>Your Demand: ${YourDemand}</p>
`;
result.style.display = 'block';
}
});