Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node_modules/
node_modules
6 changes: 5 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ <h1 class="contact_header">
I'm always interested in hearing about new projects, so if you'd
like to chat please get in touch.
</h1>
<form action="https://formspree.io/f/mgeqgkld" method="post">
<form
action="https://formspree.io/f/mgeqgkld"
method="post"
id="contact-Form"
>
<label for="full-name" hidden>Full name</label><br />
<input
type="text"
Expand Down
24 changes: 23 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ const creatProject = () => {
};

// eslint-disable-next-line no-plusplus
for (let i = 5; i >= 0; i--) {
for (let i = 5; i >= 0; i -= 1) {
creatProject();
const projectHeading = document.querySelector('.project-heading');
const ProjectTechnologies1 = document.querySelector('.Project-technologies1');
Expand Down Expand Up @@ -444,3 +444,25 @@ formSubmit.addEventListener('click', (event) => {
}
formSubmit.submit();
});

/* Local Storage */

const fullName = document.getElementById('full-name');
const message = document.getElementById('message');

function addFormData() {
const formDetails = document.getElementById('contact-Form');
const contactFormData = new FormData(formDetails);
const contactFormObject = Object.fromEntries(contactFormData.entries());
localStorage.setItem('form', JSON.stringify(contactFormObject));
}

email.addEventListener('keydown', addFormData);
fullName.addEventListener('keydown', addFormData);
message.addEventListener('keydown', addFormData);

const storedData = JSON.parse(localStorage.getItem('form') ?? '{}');

fullName.value = storedData.name ?? '';
email.value = storedData.email ?? '';
message.value = storedData.message ?? '';