-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
123 lines (116 loc) · 3.88 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
117
118
119
120
121
122
123
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Enroll in Our Program</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
background-color: #f4f4f9;
margin: 0;
padding: 0;
}
header {
background-color: #0073e6;
color: white;
padding: 10px 0;
display: flex;
align-items: center;
justify-content: center;
}
header img {
height: 50px;
margin-right: 10px;
}
header h1 {
margin: 0;
font-size: 24px;
}
form {
max-width: 400px;
margin: 20px auto;
padding: 20px;
background: white;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
input, select {
width: 100%;
margin: 10px 0;
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
background: #0073e6;
color: white;
font-size: 16px;
padding: 10px;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background: #005bb5;
}
.success-message {
font-size: 18px;
color: #28a745;
}
</style>
</head>
<body>
<header>
<h1>Enroll in Our Program</h1>
</header>
<form id="enrollmentForm">
<input type="text" id="firstName" name="firstName" placeholder="First Name" required>
<input type="text" id="lastName" name="lastName" placeholder="Last Name" required>
<input type="tel" id="phone" name="phone" placeholder="Phone Number" required>
<input type="email" id="email" name="email" placeholder="Email Address" required>
<select id="course" name="course" required>
<option value="" disabled selected>Select a Course</option>
<option value="DevOps">DevOps</option>
<option value="Cloud">Cloud</option>
</select>
<button type="submit">Submit</button>
</form>
<div id="successMessage" class="success-message" style="display: none;">
Thank you for enrolling! Your data has been successfully submitted.
</div>
<script>
const form = document.getElementById('enrollmentForm');
const successMessage = document.getElementById('successMessage');
form.addEventListener('submit', async (event) => {
event.preventDefault(); // Prevent page reload
const data = {
firstName: document.getElementById('firstName').value,
lastName: document.getElementById('lastName').value,
phone: document.getElementById('phone').value,
email: document.getElementById('email').value,
course: document.getElementById('course').value
};
try {
const response = await fetch('https://72su899n2k.execute-api.us-east-1.amazonaws.com/dev/enroll', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});
if (response.ok) {
successMessage.style.display = 'block';
form.reset();
} else {
alert('Error submitting the form. Please try again.');
}
} catch (error) {
alert('Unable to submit form. Please check your connection and try again.');
}
});
</script>
</body>
</html>