Spaces:
Running
Running
make the remove student func5ional
Browse files- admin-dashboard.html +13 -6
admin-dashboard.html
CHANGED
|
@@ -130,10 +130,10 @@
|
|
| 130 |
<option value="">Select Student</option>
|
| 131 |
</select>
|
| 132 |
</div>
|
| 133 |
-
<button type="
|
| 134 |
Remove Student
|
| 135 |
</button>
|
| 136 |
-
|
| 137 |
</form>
|
| 138 |
</div>
|
| 139 |
</div>
|
|
@@ -534,11 +534,16 @@
|
|
| 534 |
localStorage.setItem('studentData', JSON.stringify(students));
|
| 535 |
}
|
| 536 |
}
|
| 537 |
-
|
| 538 |
// Initialize student data when page loads
|
| 539 |
initializeStudentData();
|
| 540 |
|
| 541 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 542 |
function saveStudents() {
|
| 543 |
localStorage.setItem('studentData', JSON.stringify(students));
|
| 544 |
}
|
|
@@ -571,8 +576,9 @@
|
|
| 571 |
showManagementMessage('Student already exists', 'error');
|
| 572 |
}
|
| 573 |
});
|
| 574 |
-
|
| 575 |
-
document.getElementById('remove-student-btn-submit').addEventListener('click', function() {
|
|
|
|
| 576 |
const className = document.getElementById('student-class').value;
|
| 577 |
const form = document.getElementById('student-form').value;
|
| 578 |
const studentName = document.getElementById('student-to-remove').value;
|
|
@@ -604,6 +610,7 @@
|
|
| 604 |
|
| 605 |
// Reset selection
|
| 606 |
document.getElementById('student-to-remove').value = '';
|
|
|
|
| 607 |
} else {
|
| 608 |
showManagementMessage('No students found for this class/form', 'error');
|
| 609 |
}
|
|
|
|
| 130 |
<option value="">Select Student</option>
|
| 131 |
</select>
|
| 132 |
</div>
|
| 133 |
+
<button type="submit" id="remove-student-btn-submit" class="w-full bg-red-600 text-white py-2 rounded hover:bg-red-700">
|
| 134 |
Remove Student
|
| 135 |
</button>
|
| 136 |
+
</div>
|
| 137 |
</form>
|
| 138 |
</div>
|
| 139 |
</div>
|
|
|
|
| 534 |
localStorage.setItem('studentData', JSON.stringify(students));
|
| 535 |
}
|
| 536 |
}
|
|
|
|
| 537 |
// Initialize student data when page loads
|
| 538 |
initializeStudentData();
|
| 539 |
|
| 540 |
+
// Prevent form submission on enter key
|
| 541 |
+
document.getElementById('student-form').addEventListener('keypress', function(e) {
|
| 542 |
+
if (e.key === 'Enter') {
|
| 543 |
+
e.preventDefault();
|
| 544 |
+
}
|
| 545 |
+
});
|
| 546 |
+
// Function to save students to localStorage
|
| 547 |
function saveStudents() {
|
| 548 |
localStorage.setItem('studentData', JSON.stringify(students));
|
| 549 |
}
|
|
|
|
| 576 |
showManagementMessage('Student already exists', 'error');
|
| 577 |
}
|
| 578 |
});
|
| 579 |
+
// Remove student functionality
|
| 580 |
+
document.getElementById('remove-student-btn-submit').addEventListener('click', function(e) {
|
| 581 |
+
e.preventDefault();
|
| 582 |
const className = document.getElementById('student-class').value;
|
| 583 |
const form = document.getElementById('student-form').value;
|
| 584 |
const studentName = document.getElementById('student-to-remove').value;
|
|
|
|
| 610 |
|
| 611 |
// Reset selection
|
| 612 |
document.getElementById('student-to-remove').value = '';
|
| 613 |
+
document.getElementById('student-form').reset();
|
| 614 |
} else {
|
| 615 |
showManagementMessage('No students found for this class/form', 'error');
|
| 616 |
}
|