-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.html
59 lines (57 loc) · 3.18 KB
/
login.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h2 class="mt-5">เข้าสู่ระบบด้วยชื่อและนามสกุล</h2>
<form id="loginForm" class="mt-4">
<div class="form-group">
<label for="nameInput">ชื่อ:</label>
<input type="text" id="nameInput" class="form-control" required>
</div>
<div class="form-group">
<label for="surnameInput">นามสกุล:</label>
<input type="text" id="surnameInput" class="form-control" required>
</div>
<button type="submit" class="btn btn-primary mt-3">ค้นหา</button>
</form>
<div id="result" class="mt-4"></div>
</div>
<script>
document.getElementById('loginForm').addEventListener('submit', function (event) {
event.preventDefault();
const name = document.getElementById('nameInput').value;
const surname = document.getElementById('surnameInput').value;
// ส่งคำขอไปยัง Google Apps Script ด้วยชื่อและนามสกุล
fetch(`https://script.google.com/macros/s/AKfycbwObdrErhJ2FRw-K9IYAawU3kUKRUzh23SklsYh-mCMGfYMEPcDzHy7bs1omJDHeyf8hA/exec?name=${encodeURIComponent(name)}&surname=${encodeURIComponent(surname)}`)
.then(response => response.json())
.then(data => {
if (data.error) {
document.getElementById('result').innerHTML = `<p class="text-danger">${data.error}</p>`;
} else {
const resultHTML = `
<h4>ข้อมูล</h4>
<p>ชื่อ: ${data.name || 'N/A'}</p>
<p>นามสกุล: ${data.surname || 'N/A'}</p>
<p>เพศ: ${data.gender || 'N/A'}</p>
<p>อายุ: ${data.age || 'N/A'}</p>
<p>สถานะ: ${data.career || 'N/A'}</p>
<a href="selectForm.html?id=${encodeURIComponent(data.id || '')}&name=${encodeURIComponent(data.name || 'N/A')}&Id_P=${encodeURIComponent(data.Id_P || 'N/A')}&surname=${encodeURIComponent(data.surname || 'N/A')}" class="btn btn-success">เข้าสู่หน้า Select Form</a>
`;
document.getElementById('result').innerHTML = resultHTML;
}
})
.catch(error => {
console.error('Error fetching data:', error);
document.getElementById('result').innerHTML = `<p class="text-danger">เกิดข้อผิดพลาดในการดึงข้อมูล</p>`;
});
});
</script>
</body>
</html>