Changed around line 1
+ // Sample student data
+ const students = [
+ "Alice Johnson",
+ "Bob Smith",
+ "Charlie Brown",
+ "Diana Prince",
+ "Edward Cullen"
+ ];
+
+ // Initialize the student list
+ function initStudentList() {
+ const studentList = document.getElementById('student-list');
+ studentList.innerHTML = students.map(student => `
+
+ ${student}
+
+
+
+
+
+
+ `).join('');
+ }
+
+ // Save attendance function
+ function saveAttendance() {
+ const date = document.getElementById('date').value;
+ const attendanceRecords = [];
+
+ document.querySelectorAll('#student-list li').forEach((li, index) => {
+ const status = li.querySelector('.attendance-status').value;
+ attendanceRecords.push({
+ student: students[index],
+ status: status
+ });
+ });
+
+ const record = {
+ date: date,
+ attendance: attendanceRecords
+ };
+
+ displayRecord(record);
+ }
+
+ // Display attendance record
+ function displayRecord(record) {
+ const recordsContainer = document.getElementById('records-container');
+ const recordElement = document.createElement('div');
+ recordElement.className = 'record';
+ recordElement.innerHTML = `
+
${record.date}
+ ${record.attendance.map(entry => `
+
${entry.student}: ${entry.status}+ `).join('')}
+
+ `;
+ recordsContainer.prepend(recordElement);
+ }
+
+ // Event listeners
+ document.addEventListener('DOMContentLoaded', initStudentList);
+ document.getElementById('save-attendance').addEventListener('click', saveAttendance);