EHDEM commited on
Commit
25b8a4d
·
verified ·
1 Parent(s): 1147410

make the part where i choose the students name in remove student into a dropdown menu after i have picked class and form just like the other attendance form

Browse files
Files changed (1) hide show
  1. student-management.html +19 -27
student-management.html CHANGED
@@ -100,14 +100,12 @@
100
  </select>
101
  </div>
102
  </div>
103
- <div id="student-select-container" class="hidden mt-4">
104
- <label class="block text-gray-700 font-medium mb-2">Students in <span id="selected-class-form" class="font-bold"></span></label>
105
- <div class="bg-gray-50 rounded-lg p-4 max-h-60 overflow-y-auto border border-gray-200">
106
- <div id="student-list" class="space-y-2">
107
- <!-- Student names will be inserted here -->
108
- </div>
109
- </div>
110
- </div>
111
  <button id="remove-student-btn" class="w-full bg-red-600 hover:bg-red-700 text-white font-bold py-3 px-4 rounded-lg transition duration-200">
112
  <i class="fas fa-trash-alt mr-2"></i> Remove Student
113
  </button>
@@ -146,18 +144,18 @@
146
  document.getElementById('add-tab').classList.add('text-gray-500');
147
  document.getElementById('add-tab').classList.remove('text-blue-600', 'border-blue-600');
148
  });
149
-
150
  // Load students when class/form changes for removal
151
  document.getElementById('remove-class').addEventListener('change', loadStudentsForRemoval);
152
  document.getElementById('remove-form-select').addEventListener('change', loadStudentsForRemoval);
 
153
  function loadStudentsForRemoval() {
154
  const classVal = document.getElementById('remove-class').value;
155
  const formVal = document.getElementById('remove-form-select').value;
156
- const studentList = document.getElementById('student-list');
157
  const container = document.getElementById('student-select-container');
158
  const selectedClassForm = document.getElementById('selected-class-form');
159
 
160
- studentList.innerHTML = '';
161
  container.classList.add('hidden');
162
 
163
  if (classVal && formVal) {
@@ -166,15 +164,12 @@
166
  // Update the class/form display
167
  selectedClassForm.textContent = `${classVal} Form ${formVal}`;
168
 
169
- // Add each student to the list
170
  students[key].forEach(student => {
171
- const studentItem = document.createElement('div');
172
- studentItem.className = 'flex items-center p-2 hover:bg-gray-100 rounded transition-colors';
173
- studentItem.innerHTML = `
174
- <i class="fas fa-user-circle text-blue-500 mr-3"></i>
175
- <span>${student}</span>
176
- `;
177
- studentList.appendChild(studentItem);
178
  });
179
  container.classList.remove('hidden');
180
  }
@@ -213,14 +208,11 @@
213
  document.getElementById('add-success').classList.add('hidden');
214
  }, 3000);
215
  });
216
-
217
- // Remove student
218
- document.getElementById('remove-student-btn').addEventListener('click', function() {
219
- const className = document.getElementById('remove-class').value;
220
- const formVal = document.getElementById('remove-form-select').value;
221
- // Get selected student from the list (implementation depends on your selection method)
222
- const studentName = prompt("Enter the student name to remove:");
223
- if (!studentName) return;
224
  if (!studentName) {
225
  alert('Please select a student to remove');
226
  return;
 
100
  </select>
101
  </div>
102
  </div>
103
+ <div id="student-select-container" class="hidden mt-4">
104
+ <label for="student-select" class="block text-gray-700 font-medium mb-2">Students in <span id="selected-class-form" class="font-bold"></span></label>
105
+ <select id="student-select" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
106
+ <option value="">Select Student</option>
107
+ </select>
108
+ </div>
 
 
109
  <button id="remove-student-btn" class="w-full bg-red-600 hover:bg-red-700 text-white font-bold py-3 px-4 rounded-lg transition duration-200">
110
  <i class="fas fa-trash-alt mr-2"></i> Remove Student
111
  </button>
 
144
  document.getElementById('add-tab').classList.add('text-gray-500');
145
  document.getElementById('add-tab').classList.remove('text-blue-600', 'border-blue-600');
146
  });
 
147
  // Load students when class/form changes for removal
148
  document.getElementById('remove-class').addEventListener('change', loadStudentsForRemoval);
149
  document.getElementById('remove-form-select').addEventListener('change', loadStudentsForRemoval);
150
+
151
  function loadStudentsForRemoval() {
152
  const classVal = document.getElementById('remove-class').value;
153
  const formVal = document.getElementById('remove-form-select').value;
154
+ const studentSelect = document.getElementById('student-select');
155
  const container = document.getElementById('student-select-container');
156
  const selectedClassForm = document.getElementById('selected-class-form');
157
 
158
+ studentSelect.innerHTML = '<option value="">Select Student</option>';
159
  container.classList.add('hidden');
160
 
161
  if (classVal && formVal) {
 
164
  // Update the class/form display
165
  selectedClassForm.textContent = `${classVal} Form ${formVal}`;
166
 
167
+ // Add each student to the dropdown
168
  students[key].forEach(student => {
169
+ const option = document.createElement('option');
170
+ option.value = student;
171
+ option.textContent = student;
172
+ studentSelect.appendChild(option);
 
 
 
173
  });
174
  container.classList.remove('hidden');
175
  }
 
208
  document.getElementById('add-success').classList.add('hidden');
209
  }, 3000);
210
  });
211
+ // Remove student
212
+ document.getElementById('remove-student-btn').addEventListener('click', function() {
213
+ const className = document.getElementById('remove-class').value;
214
+ const formVal = document.getElementById('remove-form-select').value;
215
+ const studentName = document.getElementById('student-select').value;
 
 
 
216
  if (!studentName) {
217
  alert('Please select a student to remove');
218
  return;