CS101 Assignment#3
100% Correct
<html>
<head>
<title></title>
<script language="javascript">
function gpa_check()
{
if(window.document.frm.gpa.value=="")
{
window.document.all.frm.gpa.style.background = 'pink';
alert("Please enter GPA");
window.document.all.frm.gpa.style.background = 'white';
window.document.frm.gpa.focus();
return false;
}
if(isNaN(window.document.frm.gpa.value))
{
window.document.all.frm.gpa.style.background = 'red';
alert("Please enter numeric value only");
window.document.all.frm.gpa.style.background = 'white';
window.document.frm.gpa.focus();
return false;
}
if((window.document.frm.gpa.value<1) || (window.document.frm.gpa.value>4))
{
window.document.all.frm.gpa.style.background = 'lightskyblue';
alert("Numeric value must be between 1 and 4");
window.document.all.frm.gpa.style.background = 'white';
window.document.frm.gpa.focus();
return false;
}
if((window.document.frm.gpa.value<=1) || (window.document.frm.gpa.value<2))
{
window.document.all.frm.gpa.style.background = 'lime';
alert("Fair :: You got D grade");
window.document.frm.gpa.focus();
return true;
}
if((window.document.frm.gpa.value<=2) || (window.document.frm.gpa.value<3))
{
window.document.all.frm.gpa.style.background = 'lime';
alert("Good :: You got C grade");
window.document.frm.gpa.focus();
return true;
}
if((window.document.frm.gpa.value<=3) || (window.document.frm.gpa.value<4))
{
window.document.all.frm.gpa.style.background = 'lime';
alert("Very Good :: You got B grade");
window.document.frm.gpa.focus();
return true;
}
if(window.document.frm.gpa.value==4)
{
window.document.all.frm.gpa.style.background = 'lime';
alert("Excellent :: You got A grade");
window.document.frm.gpa.focus();
return true;
}
}
</script>
</head>
<body>
<form action="http://www.vu.edu.pk" method="post" name="frm">
<table cellpadding="0" cellspacing="0" border="0" bgcolor="#CCCCCC" width="800" align="center">
<tr><td height="20"></td></tr>
<tr>
<td align="center"><h2>Roll No :: Assignment 3 (CS101)</h2></td>
</tr>
<tr>
<td align="center">
<table cellpadding="0" cellspacing="0" border="1" width="400" align="center">
<tr>
<td width="66" height="50" align="center" bgcolor="#CCCCCC"><strong>GPA</strong></td>
<td bgcolor="#CCCCCC"> <input name="gpa" type="text" size="30" /></td>
</tr>
<tr>
<td height="50" bgcolor="#CCCCCC"> </td>
<td bgcolor="#CCCCCC"> <input type="submit" value="Grade" onClick="return gpa_check();" /></td>
</tr>
</table>
</td>
</tr>
<tr><td height="20"></td></tr>
</table>
</form>
</body>
</html>
No comments:
Post a Comment