-
Notifications
You must be signed in to change notification settings - Fork 0
/
A4.html
95 lines (82 loc) · 2.92 KB
/
A4.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student's Grades</title>
</head>
<body>
<style>
body{
background-color:aquamarine;
}
.myTable{
margin-left: auto;
margin-right: auto;
margin-top: 10px;
}
th{
width: 500px;
height: 30px;
}
</style>
<h1>Myat Thinzar Lynn - 12423051</h1>
<h2>Assignment 4</h2>
<h3>APU Grade System</h3>
<form id="inputForm">
<label for="student-id">Student ID</label>
<input type="number" id="student-id" required>
<label for="student-name">Student Name</label>
<input type="text" id="student-name" required>
<label for="marks">Marks</label>
<input type="number" id="marks" required>
<button onclick="getGrades()">Get the Grade</button>
</form>
<table border="1" id="dataTable" class="myTable">
<thead>
<tr>
<th>Student ID</th>
<th>Student Name</th>
<th>Marks</th>
<th>Grade</th>
</tr>
</thead>
<tbody></tbody>
</table>
<script>
function getGrades(){
const studentId = document.getElementById('student-id').value;
const studentName = document.getElementById('student-name').value;
const studentMarks = document.getElementById('marks').value;
let studentGrade;
if (studentMarks >= 90 && studentMarks <= 100){
studentGrade = 'A+';
}else if (studentMarks >= 80 && studentMarks <= 90){
studentGrade = "A";
}else if (studentMarks >= 70 && studentMarks <= 80){
studentGrade = "B";
}
else if (studentMarks >= 60 && studentMarks <= 70){
studentGrade = "C";
}else if (studentMarks <= 59){
studentGrade = "F";
}else{
studentGrade = "Invalid Score"
}
const table = document.getElementById('dataTable').getElementsByTagName('tbody')[0];
const newRow = table.insertRow();
const studentIdCell = newRow.insertCell(0);
const studentNameCell = newRow.insertCell(1);
const studentMarksCell = newRow.insertCell(2);
const studentGradeCell = newRow.insertCell(3);
studentIdCell.textContent = studentId;
studentNameCell.textContent = studentName;
studentMarksCell.textContent = studentMarks;
studentGradeCell.textContent = studentGrade;
document.getElementById('student-id').value = '';
document.getElementById('student-name').value = '';
document.getElementById('marks').value = '';
}
</script>
</body>
</html>