<html>
<head>
<title>Grade Calculation</title>
<script type="text/javascript">
function Add()
{
  var a=parseInt(document.getElementById("fptxt").value);
  var b=parseInt(document.getElementById("sptxt").value);
  var c=parseInt(document.getElementById("fgtxt").value);
  var d=a+b+c;

  document.getElementById("sgtxt").value=d/3;
}
//grade equivalent
if(sgtxt >= 95&& sgtxt < 100)
{
document.write("etxt").value=excellent;
}
else if(sgtxt >= 90&& sgtxt < 95)
{
document.write("etxt").value=VeryGood;
}
else if(sgtxt >= 85&& sgtxt < 89)
{
document.write("etxt").value=Good;
}
else if(sgtxt >= 80&& sgtxt < 84)
{
document.write("etxt").value=Avaerage;
}
else if(sgtxt >= 75&& sgtxt < 79)
{
document.write("etxt").value=BelowAverage;
}
else if(sgtxt < 75)
{
document.write("etxt").value=Poor;
}
else if(sgtxt < 0||sgtxt > 100)
{
 msgbox.txt("Out of Range!");
}


function clear()
{
 txt1.value="";  
  txt2.value="";  
  txt3.clear();  
    txt4.clear();  
}


</script>
</head>


    <body>
    <h1>Student Grade Calculator</h1>
    <br/>
    JavaScript
    <hr width=500 align="left">
    First Prelim Grade
    <br/>
    <input type="text" id="fptxt">
    <br/>
    Second Prelim Grade
    <br/>
    <input type="text" id="sptxt">
    <br/>
    Final Term Grade
    <br/>
    <input type="text" id="fgtxt">
    <br/>

    <input type="button" id="btnCmpute" value="Compute" onclick="Add()">
    <input type="button" id="btnclr" value="Clear" onclick="clear()">
    <br/>
    Semestral Grade<br/>
    <input type="text" id="sgtxt" >
    <br/>
    Equivalent<br/>
    <input type="text" id="etxt" >
    <hr width=500 align="left">
    <h6>Copyright© 2013<br/>
    </h3>


    </body>
    </html>

..............................................
...............................................
hi all..
just need help in printing the EQUIVALENT of grades like excellent ,good etc. on equivalent box....
.i try this codes and no one is working printing the equivalent
document.write("etxt").value=Avaerage;
document.getElementById("etxt").value=BelowAverage;
document.write("average"etxt);
...................
the clear box still not working though.....

It should be like this:

document.getElementById("etxt").value = "BelowAverage";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.