Created
December 2, 2021 07:52
-
-
Save iozhukau/3afc96ce6dd3c526c6e78acd70cf8fa8 to your computer and use it in GitHub Desktop.
Example of a form to send an email with form data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Title</title> | |
</head> | |
<body> | |
<form> | |
<label for="date">Choose a date</label> | |
<input id="date" type="date"> | |
<label for="email">Email</label> | |
<input id="email" type="email"> | |
</form> | |
<a id="link" target="_blank"> | |
<button id="button">Send mail</button> | |
</a> | |
<script> | |
document.getElementById("button").addEventListener("click", (e) => { | |
let date = document.getElementById("date").value; | |
let email = document.getElementById("email").value; | |
let title = "Hello! This mail created automatic" | |
let body = "Selected date is : " + date; | |
let href = "mailto:" + email + "?" + "subject=" + encodeURI(title) + "&" + "body=" + encodeURI(body); | |
let link = document.getElementById("link"); | |
link.setAttribute("href", href); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment