-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform.html
More file actions
316 lines (278 loc) · 13.6 KB
/
form.html
File metadata and controls
316 lines (278 loc) · 13.6 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>สมัครงาน - SE SURVEY</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600&display=swap" rel="stylesheet">
<style>
/* Reset & Global */
* { box-sizing: border-box; font-family: 'Prompt', sans-serif; margin: 0; padding: 0; }
body {
/* 2. พื้นหลังธีมเดียวกับหน้า Login */
background-color: #0a1c4c;
background-image: linear-gradient(rgba(10, 28, 76, 0.85), rgba(10, 28, 76, 0.95)),
url('https://media-public.canva.com/k3Tfs/MAGKKbk3Tfs/1/s2.png');
background-size: cover;
background-position: center;
background-attachment: fixed; /* ให้พื้นหลังนิ่งเวลาเลื่อนจอ */
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 40px 20px;
color: #333;
}
/* 3. กล่องฟอร์ม (Card Style) */
.container {
background-color: #ffffff;
padding: 40px;
border-radius: 16px;
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
width: 100%;
max-width: 600px; /* ขยายให้กว้างขึ้นเล็กน้อย */
position: relative;
}
h2 {
text-align: center;
color: #0a1c4c;
margin-bottom: 30px;
font-weight: 600;
font-size: 1.8rem;
}
.form-group {
margin-bottom: 20px;
text-align: left;
}
.form-group label {
display: block;
margin-bottom: 8px;
color: #555;
font-weight: 500;
font-size: 0.95rem;
}
/* 4. Input & Select Style */
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group select {
width: 100%;
padding: 12px 15px;
border: 1px solid #ddd;
border-radius: 8px;
font-size: 1rem;
transition: all 0.3s ease;
background-color: #f9f9f9;
outline: none;
}
.form-group input:focus,
.form-group select:focus {
border-color: #1d83e5;
background-color: #fff;
box-shadow: 0 0 0 3px rgba(29, 131, 229, 0.1);
}
/* 5. ปุ่มกด (Button Style) */
.form-group button[type="submit"] {
background-color: #1d83e5;
color: white;
padding: 14px 20px;
border: none;
border-radius: 30px; /* ทรง Pill */
cursor: pointer;
font-size: 1.1rem;
font-weight: 600;
width: 100%;
margin-top: 10px;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(29, 131, 229, 0.3);
}
.form-group button[type="submit"]:hover:not(:disabled) {
background-color: #0a66b3;
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(10, 102, 179, 0.4);
}
.form-group button[type="submit"]:disabled {
background-color: #a0a0a0;
cursor: not-allowed;
box-shadow: none;
transform: none;
}
/* Utility Classes */
.hidden { display: none; }
/* Response Messages */
#responseMessage {
margin-top: 25px;
padding: 15px;
border-radius: 8px;
display: none;
text-align: center;
font-size: 0.95rem;
line-height: 1.5;
}
#responseMessage.success {
background-color: #d1fae5;
color: #065f46;
border: 1px solid #a7f3d0;
}
#responseMessage.error {
background-color: #fee2e2;
color: #991b1b;
border: 1px solid #fecaca;
}
/* Loading Spinner */
.spinner {
border: 3px solid rgba(255, 255, 255, 0.3);
border-top: 3px solid #ffffff;
border-radius: 50%;
width: 20px;
height: 20px;
animation: spin 1s linear infinite;
display: none;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
/* Mobile Responsive */
@media screen and (max-width: 600px) {
.container { padding: 30px 20px; }
h2 { font-size: 1.5rem; }
}
</style>
</head>
<body>
<div class="container">
<h2>แบบฟอร์มสมัครงาน</h2>
<form id="jobApplicationForm">
<div class="form-group">
<label for="fullName">ชื่อ-นามสกุล:</label>
<input type="text" id="fullName" name="fullName" placeholder="กรอกชื่อและนามสกุล" required>
</div>
<div class="form-group">
<label for="address">สถานที่อยู่ปัจจุบัน:</label>
<input type="text" id="address" name="address" placeholder="บ้านเลขที่, ถนน, แขวง/ตำบล, เขต/อำเภอ" required>
</div>
<div class="form-group">
<label for="phone">เบอร์โทรศัพท์:</label>
<input type="tel" id="phone" name="phone" pattern="[0-9]{10}" placeholder="เช่น 0812345678" required>
</div>
<div class="form-group">
<label for="email">E-mail หรือ ID Line:</label>
<input type="text" id="email" name="email" placeholder="ระบุอีเมล หรือ ไอดีไลน์">
</div>
<div class="form-group">
<label for="position">ตำแหน่งที่ต้องการสมัคร:</label>
<select id="position" name="position" required>
<option value="">-- กรุณาเลือกตำแหน่ง --</option>
<option value="เจ้าหน้าที่เทคโนโลยีสารสนเทศ ( IT )">เจ้าหน้าที่เทคโนโลยีสารสนเทศ ( IT )</option>
<option value="เจ้าหน้าที่สำรวจอุบัติเหตุ ( Surveyor )">เจ้าหน้าที่สำรวจอุบัติเหตุ ( Surveyor )</option>
<option value="เจ้าหน้าที่การเงินและบัญชี">เจ้าหน้าที่การเงินและบัญชี</option>
<option value="เจ้าหน้าที่ธุรการ">เจ้าหน้าที่ธุรการ</option>
<option value="เจ้าหน้าที่บันทึกข้อมูล">เจ้าหน้าที่บันทึกข้อมูล</option>
<option value="เจ้าหน้าที่รับแจ้งอุบัติเหตุ ( Call Center )">เจ้าหน้าที่รับแจ้งอุบัติเหตุ ( Call Center )</option>
<option value="ผู้ตรวจรายงานสำรวจอุบัติเหตุ">ผู้ตรวจรายงานสำรวจอุบัติเหตุ</option>
</select>
</div>
<div class="form-group hidden" id="area-group">
<label for="area">พื้นที่ที่สะดวกปฏิบัติงาน:</label>
<input type="text" id="area" name="area" placeholder="เช่น ลาดพร้าว, บางกะปิ">
</div>
<div class="form-group">
<label for="education">วุฒิการศึกษา:</label>
<select id="education" name="education" required>
<option value="">-- กรุณาเลือกวุฒิการศึกษา --</option>
<option value="มัธยมศึกษาตอนปลาย">มัธยมศึกษาตอนปลาย</option>
<option value="ปวช.">ปวช.</option>
<option value="ปวส.">ปวส.</option>
<option value="ปริญญาตรี">ปริญญาตรี</option>
<option value="ปริญญาโท">ปริญญาโท</option>
<option value="ปริญญาเอก">ปริญญาเอก</option>
<option value="อื่นๆ">อื่นๆ</option>
</select>
</div>
<div class="form-group">
<button type="submit" id="submitButton">
<span id="buttonText">ส่งใบสมัคร</span>
<div class="spinner" id="buttonSpinner"></div>
</button>
</div>
</form>
<div id="responseMessage"></div>
</div>
<script>
const form = document.getElementById('jobApplicationForm');
const responseMessage = document.getElementById('responseMessage');
const submitButton = document.getElementById('submitButton');
const buttonText = document.getElementById('buttonText');
const buttonSpinner = document.getElementById('buttonSpinner');
// URL เดิมของคุณ
const scriptURL = 'https://script.google.com/macros/s/AKfycbxfDhOgnF9XJm36Dp3Kt9Hu-X62P2TwUAqQsWEpPO3zDTfxa8JWvHNWFq40S-GUFgyMlg/exec';
const redirectURL = 'index.html';
const redirectDelay = 2000; // เพิ่มเวลาหน่วงนิดหน่อยให้อ่านข้อความทัน
const positionSelect = document.getElementById('position');
const areaGroup = document.getElementById('area-group');
positionSelect.addEventListener('change', function () {
if (this.value === 'เจ้าหน้าที่สำรวจอุบัติเหตุ ( Surveyor )') {
areaGroup.classList.remove('hidden');
} else {
areaGroup.classList.add('hidden');
document.getElementById('area').value = '';
}
});
form.addEventListener('submit', function(e) {
e.preventDefault();
// 1. UI Loading State
submitButton.disabled = true;
buttonText.textContent = 'กำลังส่งข้อมูล...';
buttonSpinner.style.display = 'block';
responseMessage.style.display = 'none';
responseMessage.className = '';
responseMessage.textContent = '';
const formData = new FormData(form);
fetch(scriptURL, {
method: 'POST',
body: formData
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
// 2. Success State
submitButton.disabled = false;
buttonText.textContent = 'ส่งใบสมัคร';
buttonSpinner.style.display = 'none';
if (data.status === 'success') {
responseMessage.textContent = '✅ ส่งใบสมัครเรียบร้อยแล้ว! ' + data.message + ' ระบบกำลังพาท่านกลับหน้าหลัก...';
responseMessage.className = 'success';
responseMessage.style.display = 'block';
form.reset();
setTimeout(() => {
window.location.href = redirectURL;
}, redirectDelay);
} else {
responseMessage.textContent = '❌ เกิดข้อผิดพลาด: ' + (data.message || 'ไม่ทราบสาเหตุ');
responseMessage.className = 'error';
responseMessage.style.display = 'block';
}
})
.catch(error => {
// 3. Error State
submitButton.disabled = false;
buttonText.textContent = 'ส่งใบสมัคร';
buttonSpinner.style.display = 'none';
console.error('Error!', error);
responseMessage.textContent = '❌ ไม่สามารถเชื่อมต่อกับเซิร์ฟเวอร์ได้: ' + error.message;
responseMessage.className = 'error';
responseMessage.style.display = 'block';
});
});
</script>
</body>
</html>