From 8a64799627b96a3bada406eba19332f091c1941d Mon Sep 17 00:00:00 2001 From: mudasir <96320211+mud-ali@users.noreply.github.com> Date: Tue, 2 Apr 2024 15:35:04 -0400 Subject: [PATCH] client side email script (see #2) --- contactUs.html | 7 ++++--- scripts/mail.js | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 scripts/mail.js diff --git a/contactUs.html b/contactUs.html index 470795d..25a5786 100644 --- a/contactUs.html +++ b/contactUs.html @@ -41,7 +41,7 @@
CONTACT US
-
+

@@ -63,7 +63,7 @@
CONTACT US
- +
@@ -84,7 +84,8 @@
CONTACT US
- + + diff --git a/scripts/mail.js b/scripts/mail.js new file mode 100644 index 0000000..13f9b18 --- /dev/null +++ b/scripts/mail.js @@ -0,0 +1,23 @@ +const EMAIL_ADDRESS = "mail@example.com"; +const DEFAULT_SUBJECT = "Dedilse Inquiry"; +let url = `mailto:${EMAIL_ADDRESS}?subject=${encodeURIComponent(DEFAULT_SUBJECT)}`; + +const nameInput = document.getElementById("name"); +const emailInput = document.getElementById("email"); +const phoneInput = document.getElementById("phone"); +const messageInput = document.getElementById("message"); +const submitButton = document.getElementById("sendButton"); + +submitButton.addEventListener("click", (e) => { + e.preventDefault(); + e.stopPropagation(); + + let message = `${messageInput.value} + + Contact Information: + ${nameInput.value} + ${phoneInput.value} + ${emailInput.value}`; + url += `&body=${encodeURIComponent(message)}`; + window.open(url, "_blank"); +});