hello to everyone, I have this code as a Grading System, but whenever I press a key on my keyboard, it shows Not a Number or NaN! Please help! I need this by two days! Please! :(
<html>
<title>Grading System</title>
<head>
<script type="text/Javascript">
function totalM()
{
QM1 = parseInt(document.average.QM1.value);
QM2 = parseInt(document.average.QM2.value);
LQM = parseInt(document.average.LQM.value);
AM = parseInt(document.average.AM.value);
TM = parseInt(document.average.TM.value);
totalM = (QM1+QM2+LQM+AM);
document.average.TM.value = totalM;
}
function totalF()
{
QF1 = parseInt(document.average.QF1.value);
QF2 = parseInt(document.average.QF2.value);
LQF = parseInt(document.average.LQF.value);
AF = parseInt(document.average.AF.value);
TF = parseInt(document.average.TF.value);
totalF = (QF1+QF2+LQF+AF);
document.average.TF.value = totalF;
}
function averageGrade()
{
TF = parseInt(document.average.TF.value);
TM = parseInt(document.average.TM.value);
GPA = parseInt(document.average.GPA.value);
FG = parseInt(document.average.FG.value);
V = parseInt(document.average.V.value);
averageGrade = (TF+TM)/(2);
document.average.FG.value = averageGrade;
if (document.average.FG.value == 99)
{
document.average.GPA.value = "The Highest is 95" ;
document.average.V.value = "The Highest is 95";
}
else if (document.average.FG.value >= 98 && document.average.FG.value < 99)
{
document.average.GPA.value = "The Highest is 95" ;
document.average.V.value = "The Highest is 95";
}
else if (document.average.FG.value >= 97 && document.average.FG.value < 98)
{
document.average.GPA.value = "The Highest is 95" ;
document.average.V.value = "The Highest is 95";
}
else if (document.average.FG.value >= 96 && document.average.FG.value < 97)
{
document.average.GPA.value = "The Highest is 95" ;
document.average.V.value = "The Highest is 95";
}
else if (document.average.FG.value >= 95 && document.average.FG.value < 96)
{
document.average.GPA.value = "1.00" ;
document.average.V.value = "Passed";
}
else if (document.average.FG.value >= 93 && document.average.FG.value < 95)
{
document.average.GPA.value = "1.25" ;
document.average.V.value = "Passed";
}
else if (document.average.FG.value >= 90 && document.average.FG.value < 93)
{
document.average.GPA.value = "1.50" ;
document.average.V.value = "Passed";
}
else if (document.average.FG.value >= 89 && document.average.FG.value < 90)
{
document.average.GPA.value = "1.75" ;
document.average.V.value = "Passed";
}
else if (document.average.FG.value >= 85 && document.average.FG.value < 89)
{
document.average.GPA.value = "2.00" ;
document.average.V.value = "Passed";
}
else if (document.average.FG.value >= 83 && document.average.FG.value < 85)
{
document.average.GPA.value = "2.25" ;
document.average.V.value = "Passed";
}
else if (document.average.FG.value >= 80 && document.average.FG.value < 83)
{
document.average.GPA.value = "2.50" ;
document.average.V.value = "Passed";
}
else if (document.average.FG.value >= 78 && document.average.FG.value < 80)
{
document.average.GPA.value = "2.75" ;
document.average.V.value = "Passed";
}
else if (document.average.FG.value >= 75 && document.average.FG.value < 78)
{
document.average.GPA.value = "3.00" ;
document.average.V.value = "Passed";
}
else if (document.average.FG.value < 75)
{
document.average.GPA.value = "Between 3.00 and 5.00" ;
document.average.V.value = "Failed";
}
else if (isNaN(document.average.FG.value = "Not a number"))
{
document.average.GPA.value = "Not a number" ;
document.average.V.value = "Not a number";
}
}
</script>
<style type="text/css">
.style1 {
font-family: Castellar;
}
.style4 {
font-size: medium;
}
.style5 {
text-align: center;
}
</style>
</head>
<h1 class="style1" align="center" style="font-family: Castellar; font-size: xx-large; font-weight: bolder; font-style: normal; font-variant: normal; text-transform: capitalize; color: #FFFFFF; text-decoration: blink">Grading System</h1>
<form name="average" action="GS.html" method="get">
<center><h1 class="style1" align="center" style="font-family: Castellar; font-size: x-large; font-weight: bolder; font-style: normal; font-variant: normal; text-transform: capitalize; color: #FFFFFF;><table style="width: 24%; height: 179px" cellspacing="3" cellpadding="3" class="style4" border="5" bgcolor="#FFFFFF" frame="box">Midterms</h1>
<table style="width: 19%; height: 179px" cellspacing="3" cellpadding="2" class="style4" bgcolor="#FFFFFF" border="5" frame="box">
<tr>
<td class="style1">Quiz no. 1:</td>
<td class="style1">
<input name="QM1" type="text" size=2 maxlength=2>
</td>
</tr>
<tr>
<td class="style1">Quiz no. 2:</td>
<td class="style1">
<input name="QM2" type="text" size=2 maxlength=2>
</td>
</tr>
<tr>
<td class="style1">Long Quiz:</td>
<td class="style1">
<input name="LQM" type="text" size=2 maxlength=2>
</td>
</tr>
<tr>
<td class="style1">Attendance:</td>
<td class="style1">
<input name="AM" type="text" size=2 maxlength=2 onKeyPress="return totalM()">
</td>
</tr>
<tr>
<td class="style1">Total Midterms:</td>
<td class="style1">
<input type="text" name="TM" size=2 maxlength=2>
</td>
</tr>
</table>
<h1 class="style1" align="center" style="font-family: Castellar; font-size: x-large; font-weight: bolder; font-style: normal; font-variant: normal; text-transform: capitalize; color: #FFFFFF;><table style="width: 24%; height: 179px" cellspacing="3" cellpadding="3" class="style4" border="5" bgcolor="#FFFFFF" frame="box">Finals</h1>
<table style="width: 19%; height: 179px" cellspacing="3" cellpadding="2" class="style4" bgcolor="#FFFFFF" border="5" frame="box">
<tr>
<td class="style1">Quiz no. 1:</td>
<td><input name="QF1" type="text" size=2 maxlength=2></td>
</tr>
<tr>
<td class="style1">Quiz no. 2:</td>
<td class="style1">
<input name="QF2" type="text" size=2 maxlength=2>
</td>
</tr>
<tr>
<td class="style1">Long Quiz:</td>
<td class="style1">
<input name="LQF" type="text" size=2 maxlength=2>
</td>
</tr>
<tr>
<td class="style1">Attendance:</td>
<td class="style1">
<input name="AF" type="text" size=2 maxlength=2 onKeyPress="return totalF()">
</td>
</tr>
<tr>
<td class="style1">Total Finals: </td>
<td class="style1">
<input type="text" name="TF" size=2 maxlength=2 onKeyPress="return averageGrade()";>
</td>
</tr>
</table>
<br>
<table style="width: 23%; height: 70px" cellspacing="3" cellpadding="2" class="style4" bgcolor="#FFFFFF" border="5" frame="box">
<tr>
<td class="style1">Final Grade:</td>
<td class="style1"><input type=text disabled="disabled" name="FG" size=21></td>
</tr>
<tr>
<td class="style1">G.P.A.</td>
<td class="style6"><input type=text disabled="disabled" name="GPA" size=21></td>
</tr>
<tr>
<td class="style1">Verdict:</td>
<td class="style6"><input type=text disabled="disabled" name="V" size=21></td>
</tr>
</table>
<h1 class="style1" align="center" style="font-family: Castellar; font-size: x-large; font-weight: bolder; font-style: normal; font-variant: normal; text-transform: capitalize; color: #FFFFFF;><table style="width: 24%; height: 179px" cellspacing="3" cellpadding="3" class="style4" border="5" bgcolor="#FFFFFF" frame="box">
</center>
</form>
</html>