-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStudent_remove.html
More file actions
69 lines (60 loc) · 2.47 KB
/
Copy pathStudent_remove.html
File metadata and controls
69 lines (60 loc) · 2.47 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Remove Student</title>
<link rel="icon" type="image/x-icon" href="">
<link rel="stylesheet" href="Student_remove.css">
</head>
<body>
<header>
<div class="logo">
<img src="logo-.png" alt="school-logo">
</div>
<nav class="navbar">
<button type="button" class="logout-button" onclick="window.history.back();">Back</button>
</nav>
</header>
<div class="select-container">
<h2 class="title">Remove Student</h2>
<form id="removeStudentForm">
<input type="text" id="student_id" name="student_id" placeholder="Student ID Number" class="search-field" required>
<button type="submit">Submit</button>
</form>
<div id="resultMessage"></div>
</div>
<script>
document.getElementById('removeStudentForm').addEventListener('submit', function(event) {
event.preventDefault();
const studentId = document.getElementById('student_id').value;
const resultMessage = document.getElementById('resultMessage');
const xhr = new XMLHttpRequest();
xhr.open('POST', 'Student_remove.php', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function() {
if (xhr.status === 200) {
try {
const response = JSON.parse(xhr.responseText);
if (response.status === 'success') {
resultMessage.innerHTML = `<p style="color: green;">${response.message}</p>`;
document.getElementById('student_id').value = '';
} else {
resultMessage.innerHTML = `<p style="color: red;">${response.message}</p>`;
}
} catch (e) {
resultMessage.innerHTML = '<p style="color: red;">Error parsing server response</p>';
}
} else {
resultMessage.innerHTML = '<p style="color: red;">Error removing student</p>';
}
};
xhr.onerror = function() {
resultMessage.innerHTML = '<p style="color: red;">Network error. Please check your connection.</p>';
};
xhr.send(`student_id=${studentId}`);
});
</script>
</body>
</html>