Current Directory:
/home/kridsana/webapp.cm.in.th/663012801/u66301280011/P001
Upload
Create File
File Name
Size
Actions
index.php
7543 bytes
Edit
|
Delete
|
Rename
|
Download
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>คะแนนเกรดของเด็กชายธนธฤต รัตนวรรณ์</title> <style> /* CSS เดิมทั้งหมด */ body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: linear-gradient(135deg, #ffe0b2, #ffb74d, #f57c00, #e65100); background-size: 300% 300%; animation: gradientShift 10s ease infinite; display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0; color: #333; } @keyframes gradientShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } } .container { width: 100%; max-width: 800px; padding: 40px; border-radius: 15px; background-color: rgba(255, 255, 255, 0.9); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1); text-align: center; transform: translateY(50px); animation: fadeIn 1s forwards; } h2 { font-size: 2.5rem; color: #f57c00; margin-bottom: 30px; font-weight: 600; letter-spacing: 1px; } .input-group { margin-bottom: 25px; text-align: left; padding: 0 10px; } .input-group label { font-size: 1.1rem; color: #333; display: block; margin-bottom: 8px; } .input-group input { width: 100%; padding: 14px; font-size: 1rem; border: 1px solid #ddd; border-radius: 8px; background-color: #fafafa; transition: all 0.3s ease; } .input-group input:focus { border-color: #ffb74d; outline: none; background-color: #fff; } .button-group { display: flex; justify-content: space-between; gap: 20px; } .calculate-btn, .reset-btn { width: 48%; padding: 16px; font-size: 1.2rem; color: white; border: none; border-radius: 10px; cursor: pointer; transition: background-color 0.3s ease, transform 0.2s ease; } .calculate-btn { background: linear-gradient(135deg, #ffeb3b, #ff9800); } .calculate-btn:hover { background: linear-gradient(135deg, #ff9800, #ffeb3b); transform: translateY(-2px); } .reset-btn { background: linear-gradient(135deg, #ff7043, #ff5722); } .reset-btn:hover { background: linear-gradient(135deg, #ff5722, #ff7043); transform: translateY(-2px); } .result { margin-top: 30px; padding: 25px; border-top: 2px solid #ddd; font-size: 1.3rem; background-color: #fff3e0; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); display: none; /* ซ่อนผลลัพธ์ไว้ก่อน */ } .result span { display: block; margin-bottom: 10px; } @keyframes fadeIn { from { opacity: 0; transform: translateY(50px); } to { opacity: 1; transform: translateY(0); } } </style> </head> <body> <div class="container"> <h2>คะแนนเกรดของเด็กชายธนธฤต รัตนวรรณ์</h2> <form id="scoreForm"> <div class="input-group"> <label for="discipline">จิตพิสัย (20 คะแนน)</label> <input type="number" id="discipline" name="discipline" min="0" max="20" required> </div> <div class="input-group"> <label for="test">แบบทดสอบ (30 คะแนน)</label> <input type="number" id="test" name="test" min="0" max="30" required> </div> <div class="input-group"> <label for="work">งาน (20 คะแนน)</label> <input type="number" id="work" name="work" min="0" max="20" required> </div> <div class="input-group"> <label for="final_exam">สอบปลายภาค (30 คะแนน)</label> <input type="number" id="final_exam" name="final_exam" min="0" max="30" required> </div> <div class="button-group"> <button type="button" class="calculate-btn" onclick="validateAndCalculate()">ประมวลผล</button> <button type="reset" class="reset-btn" onclick="resetForm()">รีเซ็ต</button> </div> </form> <div class="result" id="result"> <span id="totalScore"></span> <span id="gradeResult"></span> </div> </div> <script> function validateAndCalculate() { const fields = [ { id: 'discipline', max: 20 }, { id: 'test', max: 30 }, { id: 'work', max: 20 }, { id: 'final_exam', max: 30 } ]; for (let field of fields) { const value = parseInt(document.getElementById(field.id).value) || 0; if (value > field.max) { alert(`กรุณากรอกคะแนนไม่เกิน ${field.max} คะแนน ในช่อง ${field.id}`); return; } } calculateGrade(); } function calculateGrade() { const discipline = parseInt(document.getElementById('discipline').value) || 0; const test = parseInt(document.getElementById('test').value) || 0; const work = parseInt(document.getElementById('work').value) || 0; const finalExam = parseInt(document.getElementById('final_exam').value) || 0; const totalScore = discipline + test + work + finalExam; let grade = ''; if (totalScore >= 80) grade = 'A'; else if (totalScore >= 75) grade = 'B+'; else if (totalScore >= 70) grade = 'B'; else if (totalScore >= 65) grade = 'C+'; else if (totalScore >= 60) grade = 'C'; else if (totalScore >= 55) grade = 'D+'; else if (totalScore >= 50) grade = 'D'; else grade = 'F'; document.getElementById('totalScore').innerText = `คะแนนรวม: ${totalScore} คะแนน`; document.getElementById('gradeResult').innerText = `เกรด: ${grade}`; document.getElementById('result').style.display = 'block'; } function resetForm() { document.getElementById('result').style.display = 'none'; } </script> </body> </html>
Save Changes