<html>
<head>
<script language="javascript" type="text/javascript">
function resetField(txtfield) {
txtfield.style.backgroundColor = "white";
txtfield.value = "";
txtfield.focus();
}
function findGrades() {
txtfield = document.getElementById("gpa");
GPA = txtfield.value;
numericvalue = parseFloat(GPA);
if(!isNaN(numericvalue)){
if(GPA == 4){
txtfield.style.backgroundColor = "lime";
window.alert("Excellent :: You got A grade");
return true;
}
else if(numericvalue >= 3 && numericvalue < 4){
txtfield.style.backgroundColor = "lime";
window.alert("Very Good :: You got B grade");
return true;
}
else if(numericvalue >= 2 && numericvalue < 3){
txtfield.style.backgroundColor = "lime";
window.alert("Good :: You got C grade");
return true;
}
else if(numericvalue >= 1 && numericvalue < 2){
txtfield.style.backgroundColor = "lime";
window.alert("Fair :: You got D grade");
return true;
}
else {
txtfield.style.backgroundColor = "lightskyblue";
window.alert("Numeric value must be between 1 and 4");
resetField(txtfield);
return false;
}
}
else if(GPA == "") {
txtfield.style.backgroundColor = "pink";
window.alert("Please enter GPA");
resetField(txtfield);
return false;
}
else {
txtfield.style.backgroundColor = "red";
window.alert("Please enter numeric value only");
resetField(txtfield);
return false;
}
}
</script>
<title>CS101 :: Assignment 3</title>
</head>
<body bgcolor="#CCCCCC">
<p> </p>
<h1 align="center">Your VU-ID Here :: Assignment 3 (CS101)</h1><br>
<form method="post" action="http://www.vu.edu.pk/">
<table width="350" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#FFFFFF">
<tr>
<td align="right" valign="middle"><strong>GPA :</strong></td>
<td height="50" align="left" valign="middle"><input name="gpa" type="text" id="gpa" size="30"></td>
</tr>
<tr>
<td>
</td>
<td height="50"><input name="submit" type="submit" id="submit" onClick="return findGrades()" value="Find Grades" style="font-weight:bold; padding:3px; width:120px;"></td>
</tr>
</table>
</form>
</body>
</html>
<head>
<script language="javascript" type="text/javascript">
function resetField(txtfield) {
txtfield.style.backgroundColor = "white";
txtfield.value = "";
txtfield.focus();
}
function findGrades() {
txtfield = document.getElementById("gpa");
GPA = txtfield.value;
numericvalue = parseFloat(GPA);
if(!isNaN(numericvalue)){
if(GPA == 4){
txtfield.style.backgroundColor = "lime";
window.alert("Excellent :: You got A grade");
return true;
}
else if(numericvalue >= 3 && numericvalue < 4){
txtfield.style.backgroundColor = "lime";
window.alert("Very Good :: You got B grade");
return true;
}
else if(numericvalue >= 2 && numericvalue < 3){
txtfield.style.backgroundColor = "lime";
window.alert("Good :: You got C grade");
return true;
}
else if(numericvalue >= 1 && numericvalue < 2){
txtfield.style.backgroundColor = "lime";
window.alert("Fair :: You got D grade");
return true;
}
else {
txtfield.style.backgroundColor = "lightskyblue";
window.alert("Numeric value must be between 1 and 4");
resetField(txtfield);
return false;
}
}
else if(GPA == "") {
txtfield.style.backgroundColor = "pink";
window.alert("Please enter GPA");
resetField(txtfield);
return false;
}
else {
txtfield.style.backgroundColor = "red";
window.alert("Please enter numeric value only");
resetField(txtfield);
return false;
}
}
</script>
<title>CS101 :: Assignment 3</title>
</head>
<body bgcolor="#CCCCCC">
<p> </p>
<h1 align="center">Your VU-ID Here :: Assignment 3 (CS101)</h1><br>
<form method="post" action="http://www.vu.edu.pk/">
<table width="350" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#FFFFFF">
<tr>
<td align="right" valign="middle"><strong>GPA :</strong></td>
<td height="50" align="left" valign="middle"><input name="gpa" type="text" id="gpa" size="30"></td>
</tr>
<tr>
<td>
</td>
<td height="50"><input name="submit" type="submit" id="submit" onClick="return findGrades()" value="Find Grades" style="font-weight:bold; padding:3px; width:120px;"></td>
</tr>
</table>
</form>
</body>
</html>
No comments:
Post a Comment