File size: 18,593 Bytes
b056f2a 1474865 b056f2a 1474865 b056f2a 1474865 b056f2a 1474865 b056f2a 1474865 b056f2a 1474865 b056f2a 1474865 b056f2a 1474865 b056f2a 1474865 b056f2a 1474865 b056f2a 1474865 b056f2a 656bfa9 b056f2a 393a80a b056f2a 393a80a b056f2a 656bfa9 b056f2a 393a80a b056f2a 656bfa9 1474865 393a80a 656bfa9 393a80a b056f2a 2da4031 1474865 2da4031 656bfa9 2da4031 1474865 2da4031 b056f2a 1474865 393a80a 1474865 393a80a b056f2a 656bfa9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | <!DOCTYPE html>
<html lang="en" class="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Data Entry</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.sheetjs.com/xlsx-0.19.3/package/dist/xlsx.full.min.js"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
body {
font-family: 'Poppins', sans-serif;
background-color: #0f172a;
color: #f8fafc;
}
.input-highlight {
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
transition: box-shadow 0.3s ease;
}
.text-gradient {
background: linear-gradient(90deg, #3b82f6, #60a5fa, #3b82f6);
background-size: 200% auto;
color: transparent;
background-clip: text;
-webkit-background-clip: text;
animation: shine 3s linear infinite;
}
@keyframes shine {
to {
background-position: 200% center;
}
}
.card-3d {
transform-style: preserve-3d;
perspective: 1000px;
box-shadow: 0 25px 50px -12px rgba(59, 130, 246, 0.25);
}
</style>
</head>
<body class="min-h-screen flex items-center justify-center p-4">
<div class="w-full max-w-4xl mx-auto">
<div class="card-3d bg-gray-800 rounded-2xl overflow-hidden relative p-8">
<h1 class="text-3xl font-bold text-center mb-2 text-gradient">Student Data Entry</h1>
<p class="text-gray-400 text-center mb-8">Enter student details to export to Excel</p>
<form id="studentForm" class="space-y-4">
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div>
<label for="student-name" class="block text-sm font-medium text-gray-300 mb-1">Full Name</label>
<div class="relative">
<input type="text" id="student-name" name="name" required minlength="3"
class="w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg focus:outline-none focus:border-blue-500 transition-all duration-300"
placeholder="John Doe">
<div class="absolute inset-0 rounded-lg pointer-events-none input-highlight hidden"></div>
</div>
</div>
<div>
<label for="student-id" class="block text-sm font-medium text-gray-300 mb-1">Student ID</label>
<div class="relative">
<input type="text" id="student-id" name="id" required
class="w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg focus:outline-none focus:border-blue-500 transition-all duration-300"
placeholder="S12345">
<div class="absolute inset-0 rounded-lg pointer-events-none input-highlight hidden"></div>
</div>
</div>
<div>
<label for="student-age" class="block text-sm font-medium text-gray-300 mb-1">Age</label>
<div class="relative">
<input type="number" id="student-age" name="age" required min="5" max="25"
class="w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg focus:outline-none focus:border-blue-500 transition-all duration-300"
placeholder="18">
<div class="absolute inset-0 rounded-lg pointer-events-none input-highlight hidden"></div>
</div>
</div>
</div>
<div>
<label for="student-address" class="block text-sm font-medium text-gray-300 mb-1">Address</label>
<div class="relative">
<textarea id="student-address" name="address" rows="2" required
class="w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg focus:outline-none focus:border-blue-500 transition-all duration-300"
placeholder="123 Main St, City"></textarea>
<div class="absolute inset-0 rounded-lg pointer-events-none input-highlight hidden"></div>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div>
<label for="math-marks" class="block text-sm font-medium text-gray-300 mb-1">Math Marks</label>
<div class="relative">
<input type="number" id="math-marks" name="math" required min="0" max="100"
class="w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg focus:outline-none focus:border-blue-500 transition-all duration-300"
placeholder="85">
<div class="absolute inset-0 rounded-lg pointer-events-none input-highlight hidden"></div>
</div>
</div>
<div>
<label for="science-marks" class="block text-sm font-medium text-gray-300 mb-1">Science Marks</label>
<div class="relative">
<input type="number" id="science-marks" name="science" required min="0" max="100"
class="w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg focus:outline-none focus:border-blue-500 transition-all duration-300"
placeholder="90">
<div class="absolute inset-0 rounded-lg pointer-events-none input-highlight hidden"></div>
</div>
</div>
<div>
<label for="english-marks" class="block text-sm font-medium text-gray-300 mb-1">English Marks</label>
<div class="relative">
<input type="number" id="english-marks" name="english" required min="0" max="100"
class="w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg focus:outline-none focus:border-blue-500 transition-all duration-300"
placeholder="78">
<div class="absolute inset-0 rounded-lg pointer-events-none input-highlight hidden"></div>
</div>
</div>
</div>
<div class="flex justify-end space-x-4 mt-6">
<button type="button" id="add-student"
class="px-6 py-2 border border-blue-500 rounded-lg shadow-sm text-sm font-medium text-blue-500 hover:bg-blue-500/10 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-all duration-300">
Add Student
</button>
<button type="button" id="export-excel"
class="px-6 py-2 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-all duration-300">
Export to Excel
</button>
<button type="reset"
class="px-6 py-2 border border-gray-500 rounded-lg shadow-sm text-sm font-medium text-gray-300 hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-gray-500 transition-all duration-300">
Clear
</button>
</div>
</form>
<div class="mt-8">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-300">Student Records</h2>
<span id="student-count" class="text-sm text-gray-400">0 students</span>
</div>
<div class="overflow-x-auto">
<table id="student-table" class="min-w-full divide-y divide-gray-700">
<thead class="bg-gray-700">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Name</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">ID</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Age</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Address</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Math</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Science</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">English</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Total</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-300 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody id="student-table-body" class="bg-gray-800 divide-y divide-gray-700">
<!-- Student records will be added here -->
</tbody>
</table>
</div>
</div>
</div>
</div>
<script>
// Initialize Feather Icons
feather.replace();
// Student data array
let students = [];
// Input highlight animation
document.querySelectorAll('input, textarea').forEach(input => {
input.addEventListener('focus', function() {
this.parentElement.querySelector('.input-highlight')?.classList.remove('hidden');
});
input.addEventListener('blur', function() {
this.parentElement.querySelector('.input-highlight')?.classList.add('hidden');
});
});
// Add student to table
document.getElementById('add-student').addEventListener('click', function() {
const form = document.getElementById('studentForm');
const name = document.getElementById('student-name').value.trim();
const id = document.getElementById('student-id').value.trim();
const age = parseInt(document.getElementById('student-age').value);
const address = document.getElementById('student-address').value.trim();
const math = parseInt(document.getElementById('math-marks').value);
const science = parseInt(document.getElementById('science-marks').value);
const english = parseInt(document.getElementById('english-marks').value);
// Validation
if (!name || !id || !age || !address || isNaN(math) || isNaN(science) || isNaN(english)) {
alert('Please fill all fields correctly');
return;
}
if (name.length < 3) {
alert('Name must be at least 3 characters');
return;
}
if (age < 5 || age > 25) {
alert('Age must be between 5 and 25');
return;
}
if ([math, science, english].some(mark => mark < 0 || mark > 100)) {
alert('Marks must be between 0 and 100');
return;
}
// Check for duplicate ID
if (students.some(s => s.id === id)) {
alert('Student ID already exists');
return;
}
// Create student object
const student = { name, id, age, address, math, science, english };
// Add to array
students.push(student);
// Add to table
addStudentToTable(student);
// Reset form
form.reset();
// Show success message
showNotification('Student added successfully', 'success');
});
// Add student to table function
function addStudentToTable(student) {
const tableBody = document.getElementById('student-table-body');
const row = document.createElement('tr');
row.className = 'hover:bg-gray-700 transition-colors duration-200';
row.dataset.id = student.id;
const totalMarks = student.math + student.science + student.english;
row.innerHTML = `
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-300">${student.name}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-300">${student.id}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-300">${student.age}</td>
<td class="px-6 py-4 text-sm text-gray-300">${student.address}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-300">${student.math}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-300">${student.science}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-300">${student.english}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-300">${totalMarks}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-300">
<button type="button" class="text-red-500 hover:text-red-400 delete-btn" onclick="deleteStudent('${student.id}', this)">
<i data-feather="trash-2" class="w-4 h-4"></i>
</button>
</td>
`;
tableBody.appendChild(row);
feather.replace();
// Update student count
document.getElementById('student-count').textContent = `${students.length} students`;
}
// Global delete function
function deleteStudent(studentId, btn) {
students = students.filter(s => s.id !== studentId);
btn.closest('tr').remove();
showNotification('Student deleted successfully', 'info');
// Update student count
document.getElementById('student-count').textContent = `${students.length} students`;
}
// Export to Excel
document.getElementById('export-excel').addEventListener('click', function() {
if (students.length === 0) {
alert('No student data to export');
return;
}
try {
// Prepare worksheet
const ws = XLSX.utils.json_to_sheet(students.map(student => ({
'Name': student.name,
'Student ID': student.id,
'Age': student.age,
'Address': student.address,
'Math Marks': student.math,
'Science Marks': student.science,
'English Marks': student.english,
'Total Marks': student.math + student.science + student.english,
'Average': ((student.math + student.science + student.english) / 3).toFixed(2)
})));
// Create workbook
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "Students");
// Generate timestamp
const timestamp = new Date().toISOString().split('T')[0];
// Export to Excel
XLSX.writeFile(wb, `student_data_${timestamp}.xlsx`);
showNotification('Excel file exported successfully', 'success');
} catch (error) {
console.error('Export error:', error);
alert('Failed to export data. Please try again.');
}
});
// Notification system
function showNotification(message, type = 'info') {
const notification = document.createElement('div');
notification.className = `fixed top-4 right-4 p-4 rounded-lg shadow-lg z-50 transition-all duration-300 ${
type === 'success' ? 'bg-green-600' : type === 'error' ? 'bg-red-600' : 'bg-blue-600'
} text-white`;
notification.textContent = message;
document.body.appendChild(notification);
setTimeout(() => {
notification.style.opacity = '0';
setTimeout(() => notification.remove(), 300);
}, 3000);
}
// Load sample data
document.addEventListener('DOMContentLoaded', function() {
// Add some sample data
const sampleStudents = [
{ name: 'Alice Johnson', id: 'S001', age: 18, address: '123 Main St, City', math: 85, science: 90, english: 78 },
{ name: 'Bob Smith', id: 'S002', age: 19, address: '456 Oak Ave, Town', math: 92, science: 88, english: 85 }
];
sampleStudents.forEach(student => {
students.push(student);
addStudentToTable(student);
});
// Initialize student count
document.getElementById('student-count').textContent = `${students.length} students`;
});
</script>
</body>
</html>
|