03.
<link rel=
"icon"
href=
"images/favicon.ico"
type=
"image/x-icon"
>
04.
<link rel=
"shortcut icon"
href=
"images/favicon.ico"
type=
"image/x-icon"
>
05.
06.
<title><< คำนวณคะเเนน >></title>
07.
08.
09.
<form action=
"page.cgi"
method=
"post"
name=
"form1"
>
10.
11.
<table width=
"100%"
border=
"1"
id=
"jj"
>
12.
<tr>
13.
<td colspan=
"6"
>ผลการเรียน</td>
14.
</tr>
15.
<tr>
16.
<td>ชื่อ</td>
17.
<td>นามสกุล</td>
18.
<td>คะเเนน1</td>
19.
<td>คะเเนน2</td>
20.
<td>รวม</td>
21.
<td>เกรด</td>
22.
</tr>
23.
<tr>
24.
25.
26.
27.
28.
<?php
include_once
"connDB.php"
;?>
29.
<?php
30.
$query
=mysqli_query(
$conn
,
"select * from grade Where id"
);
31.
while
(
$arr
= mysqli_fetch_array(
$query
)){
32.
?>
33.
34.
<td><?php
echo
$arr
[
'id'
]?><?php
echo
$arr
[
'name'
]?></td>
35.
<td><?php
echo
$arr
[
'lastname'
]?></td>
36.
<td><input type=
"text"
rel=
"1"
id=
"point<?php echo $arr['id']?>_1"
value=
""
</td>
37.
<td><input type=
"text"
rel=
"1"
id=
"point<?php echo $arr['id']?>_2"
</td>
38.
<td><input type=
"text"
rel=
"1"
id=
"total<?php echo $arr['id']?>"
value=
""
/></td>
39.
<td><input type=
"text"
rel=
"1"
id=
"G<?php echo $arr['id']?>"
size=
"5"
maxlength=
"3"
/></tr>
40.
41.
42.
<?php } ?>
43.
45.
<script>
46.
$(document).ready(
function
(){
47.
48.
$(
'#jj'
).on(
'keyup'
,
'input'
,
function
(e){
49.
e.preventDefault();
50.
var
rel=
''
;
51.
var
grade=
''
;
52.
rel=$(this).attr(
'rel'
);
53.
54.
point1=parseInt($(
'#point'
+rel+
'_1'
).val());
55.
point2=parseInt($(
'#point'
+rel+
'_2'
).val());
56.
total=point1+point2
57.
$(
'#total'
+rel).val(total);
58.
59.
if
(total < 50){
60.
grade=
'f'
;
61.
}
else
if
(total >= 50 && total <=59){
62.
grade=
'D'
;
63.
}
else
if
(total >= 60 && total <=69){
64.
grade=
'C'
;
65.
}
else
if
(total >= 70 && total <=79){
66.
grade=
'B'
;
67.
}
else
if
(total >= 80){
68.
grade=
'A'
;
69.
}
70.
$(
'#'
+rel).
empty
().append(grade);
71.
72.
});
73.
74.
});
75.
</script>
76.
77.
78.
</table>
79.
</form>
80.
81.
82.
</body>
83.
</html>