-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
116 lines (110 loc) · 4.33 KB
/
index.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
body{
background-image: url(https://images.unsplash.com/photo-1551623134-658abf4a311b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1234&q=80);
font-family:'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
}
form{
background-color:rgb(252, 252, 252);
border-radius: 10px;
padding: 20px;
box-shadow: 2px, 2px, 5px, rgb(2, 2, 2);
}
button{
height: 36px;
width: 56px;
background-color:rgb(185, 209, 209);
margin: 2px;
}
label{
margin-top: 100px;
}
input{
height: 36px;
width: 150px;
margin: 5px;
}
#courseName{
width: 500px;
}
#sendButton{
position:fixed;
bottom: 10px;
right: 30px;
width: 80vw;
}
</style>
</head>
<body>
<form>
<br>
<label>Number of Certificates:</label>
<br>
<button onclick="addFields(1); return false">One</button>
<button onclick="addFields(2); return false">Two</button>
<button onclick="addFields(3); return false">Three</button>
<button onclick="addFields(4); return false">Four</button>
<button onclick="addFields(5); return false">Five</button>
<br>
<button onclick="addFields(6); return false">Six</button>
<button onclick="addFields(7); return false">Seven</button>
<button onclick="addFields(8); return false">Eight</button>
<button onclick="addFields(9); return false">Nine</button>
<button onclick="addFields(10); return false">Ten</button>
<br>
<label> Course Name:
<input type="text" id="courseName"></label>
<div id="container"></div>
</form>
<button id="sendButton" onclick="sendMail(); return false">Send</button>
</body>
<script>
function addFields(number){
let container = document.getElementById("container");
// Clear previous contents of the container
while (container.hasChildNodes()) {
container.removeChild(container.lastChild);
}
for (i=0;i<number;i++){
// Append a node with a random text
container.appendChild(document.createTextNode("Email " + (i+1)));
// Create an <input> element, set its type and name attributes
let emailInput = document.createElement("input");
emailInput.type = "email";
emailInput.className = 'recipient';
container.appendChild(emailInput);
// Append a line break
container.appendChild(document.createTextNode("Name " + (i+1)));
let nameInput = document.createElement("input");
nameInput.type = "text";
nameInput.className = 'learnerName';
container.appendChild(nameInput);
container.appendChild(document.createElement("br"));
}
}
function sendMail() {
// pull input infomration into an object
let mailInfo = {
address: document.getElementsByClassName('recipient'),
learnerName: document.getElementsByClassName('learnerName'),
course: document.getElementById('courseName').value,
};
//for each email input sends an email with email and name of the same iterator
for (let property in mailInfo.address) {
if (mailInfo.address.hasOwnProperty(property)) {
let email = mailInfo.address[property].value;
let name = mailInfo.learnerName[property].value;
let emailBody = `Dear ${name}:%0D%0A %0D%0A
We are pleased to send the attached Certificate of Completion for the Wilmette Institute course: ${mailInfo.course}. Thank you for completing the self-assessment survey telling us about your course experience. We are always eager to hear more about how the Wilmette Institute serves our participants, faculty and learners alike.
%0D%0A %0D%0A`;
let link = "mailto:" + email + '?cc=learn@wilmetteinstitute.org&subject=Wilmette Institute Certificate' + "&body=" + emailBody;
;
window.location.href = link;
}
}
}
</script>
</html>