Skip to content

Commit

Permalink
client side email script (see #2)
Browse files Browse the repository at this point in the history
  • Loading branch information
mud-ali committed Apr 2, 2024
1 parent f3977b8 commit 8a64799
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
7 changes: 4 additions & 3 deletions contactUs.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<h5 class="contactCont">CONTACT US</h5>
</div>

<form>
<form id="contactForm">
<div>
<label for="name">Name</label> <br/>
<input type="text" name="name" id="name"/>
Expand All @@ -63,7 +63,7 @@ <h5 class="contactCont">CONTACT US</h5>
</div>

<div>
<button type="submit">SEND</button>
<button type="submit" id="sendButton">SEND</button>
</div>
</form>

Expand All @@ -84,7 +84,8 @@ <h5 class="contactCont">CONTACT US</h5>
</ul>
</footer>

<script src="./scripts/nav.js"></script>
<script src="scripts/nav.js"></script>
<script src="scripts/mail.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script> M.AutoInit();</script>
</body>
Expand Down
23 changes: 23 additions & 0 deletions scripts/mail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const EMAIL_ADDRESS = "[email protected]";
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");
});

0 comments on commit 8a64799

Please sign in to comment.