0% found this document useful (0 votes)
9 views3 pages

Ex 7

Uploaded by

asaithambiasdf71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Ex 7

Uploaded by

asaithambiasdf71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

7.Create a form for Student information.

Write JavaScript code to find Total,

Average, Result and Grade.

Html Code:

<html>

<head>

<title> Student Marks Report </title>

<script type="text/javascript">

function showResult()

var name = document.getElementById("name").value;

var cls=document.getElementById("class").value;
var marks1=parseInt(document.getElementById("Sub1").value);
var marks2=parseInt(document.getElementById("Sub2").value);
var marks3=parseInt(document.getElementById("Sub3").value);
var total=marks1+marks2+marks3;
var avg=total/3;
var grade,result;
if(avg>=60)
{
grade="A";
result="First Class";
}
else if(avg<60 && avg>=50)
{
grade="B";
result="Second Class";
}
else if(avg<50 && avg>=40)
{
grade="C";
result="Third Class";

}
else
{
grade="D";
result="Fail";
}
document.write("<body bgcolor=pink>");
document.write("<h2> Student Marks Report </h2>");
document.write("<hr>");
document.write("<b> Name :"+name+"</b> <br><br>");
document.write("<b> Class :"+cls+"</b> <br><br>");
document.write("<b> Total Marks :"+total+"</b> <br><br>");
document.write("<b> Average :"+avg+"</b> <br><br>");
document.write("<b> Grade :"+grade+"</b> <br><br>");

document.write("<b> Result :"+result+"</b> <br><br>");


document.write("</body>");
}
</script>
</head>
<body bgcolor=cyan>
<form>
<table border="5">
<tr> <th> Student Data Form </th> </tr>
<tr>
<td> Student Name </td>
<td><input type=text id=name></td>
</tr>
<tr>
<td> Class </td>
<td><input type=text id=class></td>
</tr>
<tr>
<td> Subject1 Marks </td>
<td><input type=text id=sub1></td>
</tr>
<tr>
<td> Subject2 Marks </td>
<td><input type=text id=sub2></td>
</tr>
<tr>
<td> Subject3 Marks </td>
<td><input type=text id=sub3></td>
</tr>
</table> <br> <br>
<input type=button value="ShowResult" onclick="showResult()">
</form>
</body>
</html>

You might also like