Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>MIU</title>
- <!--location of script => /home/userName/www/jquery.js-->
- <script src="jquery-1.11.1.min.js"> </script>
- <script>
- // description of function
- // by Enkh-Urnux
- function jason(num_grade){
- if (num_grade >=90)
- return "A";
- else if (num_grade >=80)
- return "B";
- else if (num_grade >=70)
- return "C";
- else if (num_grade >=60)
- return "D";
- else
- return "F";
- } // end of grade function
- // beginning of main function
- $(document).ready(function(){ //or => $(function(){
- $("#show").hide();
- $("#result").hide();
- $("#btLogin").click(function(){
- var login = jQuery("#login").val();
- var password = $("#password").val();
- if(login == "miu"){
- alert("Welcome " + login);
- $("#show").show();
- }else
- alert("Who are you?");
- });
- $("#btGrade").click(function(){
- var name = $("#name").val();
- var id = $("#id").val();
- var java = $("#java").val();
- var web = $("#web").val();
- var cpp = $("#cpp").val();
- var total = parseInt(java)+parseInt(web)+parseInt(cpp);
- var average = parseInt(total/3);
- var scJava = parseInt(java);
- var scWeb = parseInt(web);
- var scCpp = parseInt(cpp);
- var array = [scJava, scWeb, scCpp];
- if( isNaN(scJava) || scJava > 100 || isNaN(scWeb) || scWeb > 100 || isNaN(scCpp) || scCpp > 100){
- alert("Insert value between 0 and 100");
- }else{
- $("#result").show();
- $("#grade").html(
- "Name : " + name
- + "<br>Student ID : " + id
- + "<br><br>Total of your score : " + total
- + "<br>Average of your score : " + average
- + "<br>Your highest score : " + Math.max.apply(Math, array)
- + "<br>Your lowest score : " + Math.min.apply(Math, array)
- + "<br><br>Java: " + jason(scJava) + "<br>Web: " + jason(scWeb) + "<br>C++: " + jason(scCpp)
- );
- } //end of else
- }); //end of btGrade click
- }); //end of main function
- </script>
- </head>
- <body>
- <label>Login</label>
- <input id="login" type="text"><br>
- <label>Password</label>
- <input id="password" type="password">
- <button id="btLogin">Login</button>
- <br><br>
- <div id="show">
- <h1>Grade</h1>
- <label>Name</label>
- <input id="name" type="text">
- <label>Student ID</label>
- <input id="id" type="text"><br>
- <label>Java</label>
- <input id="java" type="text" >
- <label>Web</label>
- <input id="web" type="text" >
- <label>C++</label>
- <input id="cpp" type="text" ><br>
- <button id="btGrade" >Click</button>
- </div>
- <div id="result">
- <h1>Result</h1>
- <p id="grade"></p>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment