Admin Admin
Posts : 638 Points : 2155 Reputation : 19 Join date : 2010-05-15 Age : 36 Location : islamabad
| Subject: CS101 ASSIGNMENT NO 3 SOLUTION FALL 2010 Thu Jan 06, 2011 12:45 pm | |
| - Code:
-
<html> <head> <title>Untitled Document</title> <script type="text/javascript" language="javascript"> function check(numstr) { var a=document.getElementById('fid').value; var regex1=/^[0-9-.]*$/; if(document.theform.grd.value.length<1) {
document.theform.grd.style.backgroundColor="pink"; alert("Please enter CGPA!"); document.theform.grd.style.backgroundColor="white"; document.getElementById('fid').focus(); } else if(regex1.test(a)==false) { document.theform.grd.style.backgroundColor="red"; alert("Please enter numeric value only"); document.theform.grd.style.backgroundColor="white"; document.getElementById('fid').focus(); } else if(document.theform.grd.value>4 || document.theform.grd.value<1) { document.theform.grd.style.backgroundColor="lightskyblue"; alert("Numeric Value Must be Between 0 and 4"); document.theform.grd.style.backgroundColor="white"; document.getElementById('fid').focus(); } else if(document.theform.grd.value>=1 && document.theform.grd.value<2) { document.theform.grd.style.backgroundColor="lime"; alert("Fair :: You got D grade"); document.theform.submit(); } else if(document.theform.grd.value>=2 && document.theform.grd.value<3) { document.theform.grd.style.backgroundColor="lime"; alert("Good :: You got C grade"); document.theform.submit(); } else if(document.theform.grd.value>=3 && document.theform.grd.value<4) { document.theform.grd.style.backgroundColor="lime"; alert("Very Good :: You got B grade"); document.theform.submit(); } else if(document.theform.grd.value=4) { document.theform.grd.style.backgroundColor="lime"; alert("Excellent :: You got A grade "); document.theform.submit(); }
} </script> </head>
<body bgcolor="#666666"> <h1 align="center">StudentID :: Assignment 3 (CS101)</h1> <form name="theform" action="http://www.vu.edu.pk"> <table border="1px" align="center" cellpadding="10px" cellspacing="1px"> <tr> <td width="46"> CGPA </td> <td width="199"> <input type="text" width="20px" name="grd" id="fid" /> </td> </tr> <tr> <td>
</td> <td> <input type="button" value="Find Grade" onClick="check()"/> </td> </tr> </table> </form> </body> </html> | |
|