Spaces:
Running
Running
Update index.html
Browse files- index.html +35 -23
index.html
CHANGED
|
@@ -377,32 +377,44 @@
|
|
| 377 |
easing: 'ease', // Easing option
|
| 378 |
once: true // Only animate elements once
|
| 379 |
});
|
| 380 |
-
document.addEventListener("DOMContentLoaded", function() {
|
| 381 |
-
const contactForm = document.getElementById("contactForm");
|
| 382 |
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 404 |
});
|
| 405 |
});
|
|
|
|
| 406 |
</script>
|
| 407 |
</body>
|
| 408 |
</html>
|
|
|
|
| 377 |
easing: 'ease', // Easing option
|
| 378 |
once: true // Only animate elements once
|
| 379 |
});
|
|
|
|
|
|
|
| 380 |
|
| 381 |
+
const form = document.querySelector('form');
|
| 382 |
+
|
| 383 |
+
form.addEventListener('submit', (event) => {
|
| 384 |
+
event.preventDefault(); // Prevent default form submission
|
| 385 |
+
|
| 386 |
+
const name = document.getElementById('name').value;
|
| 387 |
+
const email = document.getElementById('email').value;
|
| 388 |
+
const message = document.getElementById('message').value;
|
| 389 |
+
|
| 390 |
+
// Construct email content
|
| 391 |
+
const body = `
|
| 392 |
+
Name: ${name}\n
|
| 393 |
+
Email: ${email}\n
|
| 394 |
+
Message:\n
|
| 395 |
+
${message}
|
| 396 |
+
`;
|
| 397 |
+
|
| 398 |
+
// Optional: Add validation for name, email, and message
|
| 399 |
+
|
| 400 |
+
// Send email using a dedicated library or service
|
| 401 |
+
// Example using a hypothetical library:
|
| 402 |
+
sendEmail({
|
| 403 |
+
to: '[email protected]',
|
| 404 |
+
subject: 'New Contact Form Submission',
|
| 405 |
+
body: body,
|
| 406 |
+
})
|
| 407 |
+
.then(() => {
|
| 408 |
+
// Clear form fields and display a success message
|
| 409 |
+
form.reset();
|
| 410 |
+
alert('Message sent successfully!');
|
| 411 |
+
})
|
| 412 |
+
.catch((error) => {
|
| 413 |
+
console.error('Error sending email:', error);
|
| 414 |
+
alert('An error occurred while sending the message. Please try again.');
|
| 415 |
});
|
| 416 |
});
|
| 417 |
+
|
| 418 |
</script>
|
| 419 |
</body>
|
| 420 |
</html>
|