EHDEM commited on
Commit
f63f75e
·
verified ·
1 Parent(s): 756aa8a

make it so after i have chose class and form a drop down menu like in students-ate.html appears with the students names

Browse files
Files changed (1) hide show
  1. attendance.html +37 -8
attendance.html CHANGED
@@ -154,9 +154,9 @@
154
  </select>
155
  </div>
156
  </div>
157
- <div id="student-container" class="hidden mt-4">
158
- <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>
159
- <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">
160
  <option value="">Select Student</option>
161
  </select>
162
  </div>
@@ -262,11 +262,40 @@ function updateDateTime() {
262
  document.getElementById('menu-display-container').classList.add('hidden');
263
  document.getElementById('attendance-form').classList.remove('hidden');
264
  }
265
- // Automatically load students when class or form changes
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  document.getElementById('class').addEventListener('change', loadStudents);
267
  document.getElementById('form').addEventListener('change', loadStudents);
268
- // Initialize student dropdown based on initial selections
269
- loadStudents();
 
270
  // Fill Again button
271
  document.getElementById('fill-again-btn').addEventListener('click', function() {
272
  resetForm();
@@ -681,7 +710,7 @@ studentContainer.classList.remove('hidden');
681
  studentContainer.classList.add('hidden');
682
  }
683
  }
684
- // Function to reset the form
685
  function resetForm() {
686
  // Clear form fields
687
  const classVal = document.getElementById('class').value;
@@ -699,7 +728,7 @@ studentContainer.classList.remove('hidden');
699
  document.getElementById('student-container').classList.add('hidden');
700
  }
701
  }
702
- // Automatically load students when class or form changes
703
  document.getElementById('class').addEventListener('change', loadStudents);
704
  document.getElementById('form').addEventListener('change', loadStudents);
705
 
 
154
  </select>
155
  </div>
156
  </div>
157
+ <div id="student-container" class="hidden">
158
+ <label for="student" class="block text-gray-700 font-medium mb-2">Student Name</label>
159
+ <select id="student" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
160
  <option value="">Select Student</option>
161
  </select>
162
  </div>
 
262
  document.getElementById('menu-display-container').classList.add('hidden');
263
  document.getElementById('attendance-form').classList.remove('hidden');
264
  }
265
+ // Load students based on selected class and form
266
+ function loadStudents() {
267
+ const classVal = document.getElementById('class').value;
268
+ const formVal = document.getElementById('form').value;
269
+ const studentContainer = document.getElementById('student-container');
270
+ const studentSelect = document.getElementById('student');
271
+
272
+ studentSelect.innerHTML = '<option value="">Select Student</option>';
273
+
274
+ if (classVal && formVal) {
275
+ const key = `${classVal}-${formVal}`;
276
+ if (students[key]) {
277
+ // Add each student to the dropdown
278
+ students[key].forEach(student => {
279
+ const option = document.createElement('option');
280
+ option.value = student;
281
+ option.textContent = student;
282
+ studentSelect.appendChild(option);
283
+ });
284
+ studentContainer.classList.remove('hidden');
285
+ } else {
286
+ studentContainer.classList.add('hidden');
287
+ }
288
+ } else {
289
+ studentContainer.classList.add('hidden');
290
+ }
291
+ }
292
+
293
+ // Automatically load students when class or form changes
294
  document.getElementById('class').addEventListener('change', loadStudents);
295
  document.getElementById('form').addEventListener('change', loadStudents);
296
+
297
+ // Initialize student dropdown based on initial selections
298
+ loadStudents();
299
  // Fill Again button
300
  document.getElementById('fill-again-btn').addEventListener('click', function() {
301
  resetForm();
 
710
  studentContainer.classList.add('hidden');
711
  }
712
  }
713
+ // Function to reset the form
714
  function resetForm() {
715
  // Clear form fields
716
  const classVal = document.getElementById('class').value;
 
728
  document.getElementById('student-container').classList.add('hidden');
729
  }
730
  }
731
+ // Automatically load students when class or form changes
732
  document.getElementById('class').addEventListener('change', loadStudents);
733
  document.getElementById('form').addEventListener('change', loadStudents);
734