<html>
<head>
<title>student details</title>
<script language="JavaScript">
function sum()
{
window.document.form1.total.value=parseInt(s1.value)+
      parseInt(s2.value)+
                                  parseInt(s3.value)+
                                  parseInt(s4.value)+
                                  parseInt(s5.value);
}
function grd()
{
var s1,s2,s3,s4,s5,avg;
s1=parseInt(window.document.form.s1.value);
s2=parseInt(window.document.form.s2.value);
s3=parseInt(window.document.form.s3.value);
s4=parseInt(window.document.form.s4.value);
s5=parseInt(window.document.form.s5.value);
avg=(s1+s2+s3+s4+s5)/5;
if((s1>=40)&&(s2>=40)&&(s3>=40)&&(s4>=40)&&(s5>=40))
{
if(avg>=70)
window.document.grade.value="distinction";
if(avg>=60)
window.document.grade.value="a grade";
if(avg>=50)
window.document.grade.value="b grade";
if(avg>=40)
window.document.grade.value="c grade";
else
window.document.form1.grade.value="fail";
alert("sorry u need to improve");
}
alert("congratulations");
}
function get()
{
document.writeln("<center><b> entered std info of</b>"+
window.document.form1.name.value+"</center>"+<"br>+
window.document.form1.name.value+"<br>"+"fathers name:"+
window.document.form1.fath.value+"<br>"+"fathers name:"+
window.document.form1.gender1.checked+"<br>"+"course:"+
window.document.form1.crs.value+"<br>"+"address:"+
window.document.form1.add.value+"<br>"+"subject1:"+
window.document.form1.s1.value+"<br>"+"subject2:"+
window.document.form1.s2.value+"<br>"+"subject3:"+
window.document.form1.s3.value+"<br>"+"subject4:"+
window.document.form1.s4.value+"<br>"+"subject5:"+
window.document.form1.s5.value+"<br>"+"total:"+
window.document.form1.total.value+"<br>"+"result:"+
window.document.form1.grade.value);
}
</script>
</head>
<center /><body bgcolor="red"><font color="blue" size=5>student details</font>
<form name="form1><center><b> 
father's name <input type="text" size="20" name="fath"><br><br>
student name  <input type="text" size="20" name="name"><br><br>
father's name <input type="text" size="20" name="fath"><br><br>
course<select name="crs">
<option>mca
<option>mba
<option>btech
<option>ba</select>
<input type="radio" name="gender1"> male
<input type="radio" name="gender1">female<br><br>
address<textarea name="add" cols=20 rows=3>
</textarea><br><br>
subject1<input type="text" size=10 name="s1"><br>
subject2<input type="text" size=10 name="s2"><br>
subject3<input type="text" size=10 name="s3"><br>
subject4<input type="text" size=10 name="s4"><br>
subject5<input type="text" size=10 name="s5"><br>
total<input type="text" size=10 name="total"><br>
grade<input type="text" size=10 name="grade"><br>
<input type="button" size=10 value="total" onClick="sum()">
<input type="button" size=10 value="grade" onClick="grd()">
<input type="button" size=10 value="submit" onClick="get()">
</b>
</center></form></body></html>

Edited 3 Years Ago by Dani: Formatting fixed

what's the question?

did i wrote the if condition correctly in the function grd()

This article has been dead for over six months. Start a new discussion instead.