-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontact.js
More file actions
38 lines (33 loc) · 1.24 KB
/
contact.js
File metadata and controls
38 lines (33 loc) · 1.24 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
// Create the popup element
const popup = document.createElement('div');
popup.id = 'popup-message';
document.body.appendChild(popup);
// Popup function
function showPopup(message) {
popup.textContent = message;
popup.classList.add('display');
setTimeout(() => {
popup.classList.remove('display');
}, 2500);
}
// Contact form submission
document.getElementById("contactForm").addEventListener("submit", function(event) {
event.preventDefault(); // Prevent form from submitting normally
let parms = {
name: document.getElementById("name").value,
email: document.getElementById("email").value,
subject: document.getElementById("subject").value,
message: document.getElementById("message").value,
};
// Add this line to check what's being sent
console.log("Sending parameters:", parms);
emailjs.send("service_9s13aj6", "template_e3ade2k", parms)
.then(function() {
showPopup("✅ Email sent successfully!");
document.getElementById("contactForm").reset(); // Clear the form
})
.catch(function(error) {
showPopup("❌ Failed to send email. Please try again.");
console.error("EmailJS error:", error);
});
});