SIMS HTML
SIMS HTML
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
body {
background-color: #f4f4f9;
margin: 0;
padding: 0;
.container {
max-width: 900px;
margin: 0 auto;
padding: 20px;
background-color: white;
border-radius: 8px;
h1 {
text-align: center;
color: #333;
h2 {
margin-bottom: 10px;
color: #444;
margin-bottom: 20px;
input {
width: 100%;
padding: 10px;
margin: 5px 0;
border-radius: 4px;
button {
border: none;
background-color: #5c6bc0;
color: white;
font-size: 16px;
cursor: pointer;
border-radius: 4px;
button:hover {
background-color: #3f4f88;
ul {
list-style-type: none;
padding: 0;
li {
background-color: #fafafa;
margin: 10px 0;
padding: 15px;
border-radius: 4px;
display: flex;
justify-content: space-between;
align-items: center;
}
li button {
background-color: #f44336;
border: none;
cursor: pointer;
border-radius: 4px;
li button:hover {
background-color: #e53935;
li .edit-button {
background-color: #4caf50;
li .edit-button:hover {
background-color: #45a049;
input[type="text"]:focus, input[type="number"]:focus {
border-color: #5c6bc0;
outline: none;
}
</style>
</head>
<body>
<div class="container">
<div class="form-container">
<form id="student-form">
</form>
</div>
<div class="search-container">
</div>
<div class="student-list">
<h2>Students List</h2>
<ul id="students-list"></ul>
</div>
</div>
<script>
form.addEventListener('submit', addStudent);
// Add Student
function addStudent(e) {
e.preventDefault();
const newStudent = {
id: Date.now(),
name: name,
age: age,
class: studentClass,
};
students.push(newStudent);
renderStudentList();
form.reset();
function renderStudentList() {
studentList.innerHTML = '';
students.forEach(student => {
const li = document.createElement('li');
li.innerHTML = `
<div>
<button onclick="deleteStudent(${student.id})">Delete</button>
</div>
`;
studentList.appendChild(li);
});
}
// Delete Student
function deleteStudent(id) {
renderStudentList();
// Edit Student
function editStudent(id) {
if (student) {
document.getElementById('student-name').value = student.name;
document.getElementById('student-age').value = student.age;
document.getElementById('student-class').value = student.class;
// Search Functionality
function searchStudent() {
student.name.toLowerCase().includes(searchTerm)
);
renderFilteredList(filteredStudents);
function renderFilteredList(filteredStudents) {
studentList.innerHTML = '';
filteredStudents.forEach(student => {
const li = document.createElement('li');
li.innerHTML = `
<div>
<button onclick="deleteStudent(${student.id})">Delete</button>
</div>
`;
studentList.appendChild(li);
});
// Initial Render
renderStudentList();
</script>
</body>
</html>