-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.html
79 lines (69 loc) · 3.44 KB
/
contact.html
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact Us - Watts Ecology</title>
<link rel="stylesheet" href="css/style.css"> <!-- Link to your CSS file -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<header>
<h1>Contact Watts Ecology</h1>
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</nav>
</header>
<main>
<section>
<h2>Get in Touch</h2>
<p>We'd love to hear from you! Whether you have a question about our services or need assistance with your
ecological project, our team is here to help.</p>
<!-- Form for collecting user's name and message to send an email -->
<form class="container ml-0" id="contactForm"> <!-- Replace with your form submission endpoint -->
<div class="form-group row">
<label for="name" class="col-sm-2 col-form-label">Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="name" name="name" required>
</div>
</div>
<div class="form-group row">
<label for="message" class="col-sm-2 col-form-label">Message:</label>
<div class="col-sm-10">
<textarea id="message" class="form-control" name="message" rows="4" required></textarea>
</div>
</div>
<!-- Button triggers the sendEmail function instead of submitting the form -->
<div class="form-group row">
<div class="col-sm-12 text-right"> <!-- Use the text-right class to align the button to the right -->
<button type="submit" class="btn btn-primary" onclick="sendEmail()">Send Email</button>
</div>
</div>
</form>
</section>
</main>
<footer>
<p>Back to <a href="index.html">Home</a></p>
</footer>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.2/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script>
function sendEmail() {
const email = "info@wattsecology.com"; // Recipient email address
const emailSubjectText = "Ecology query"; // Email subject line
const newline = '%0D%0A'; // URL-encoded newline character sequence for readability in email body
// Retrieves user input from the form
const name = document.getElementById('name').value;
const message = document.getElementById('message').value;
const subject = encodeURIComponent(emailSubjectText); // Encodes the subject for URL
const emailBody = `Name: ${name + newline + newline + message}`; // Formats the email body using string interpolation
// Constructs the mailto link and opens it, triggering the default email client
window.location = `mailto:${email}?subject=${subject}&body=${emailBody}`;
}
</script>
</body>
</html>