等级计算器Javascript

等级计算器Javascript,javascript,forms,addition,parsefloat,Javascript,Forms,Addition,Parsefloat,我一直在努力让这个代码发挥作用,它应该会提醒我收到的字母等级,我到处寻找帮助,我觉得我只是忽略了一些东西。请告诉我我做错了什么 <!DOCTYPE html> <HTML> <HEAD> <TITLE>Javascript Grade Calculator</TITLE> <body style="background-color: yellow"> <H1> <style=" color: b

我一直在努力让这个代码发挥作用,它应该会提醒我收到的字母等级,我到处寻找帮助,我觉得我只是忽略了一些东西。请告诉我我做错了什么

<!DOCTYPE html>

<HTML>
 <HEAD>
  <TITLE>Javascript Grade Calculator</TITLE>
  <body style="background-color: yellow">
<H1> <style=" color: black; font-family: Times New Roman" align="center"><u>Grade Calculator</u> </H1>
<h2>Directions: To use this calculator just enter your points for each item in the input boxes, then press the "Calculate" button to see your total points.</h2>   
<h3>         </h3>


<SCRIPT LANGUAGE="JavaScript">

  function do_addition()
     {

      var lab1 = parseFloat(document.form1.Lab1Score.value);
      var lab2 = parseFloat(document.form2.Lab2Score.value);
      var lab3 = parseFloat(document.form3.Lab3Score.value);
      var lab4 = parseFloat(document.form4.Lab4Score.value);
      var lab5 = parseFloat(document.form5.Lab5Score.value);
      var lab6 = parseFloat(document.form6.Lab6Score.value);
      var test1 = parseFloat(document.form7.Test1Score.value);
      var test2 = parseFloat(document.form8.Test2Score.value);
      var test3 = parseFloat(document.form9.Test3Score.value);
      var cp = parseFloat(document.form10.ClassScore.value);
      var sum = (lab1 + lab2 + lab3 + lab4 + lab5 + lab6 + test1 + test2 + test3 + cp); 

 alert("The value of Lab 1 is "+lab1+" so I got to the function");
 alert("The value of Lab 2 is "+lab2+" so I got to the function");
 alert("The value of Lab 3 is "+lab3+" so I got to the function");
 alert("The value of Lab 4 is "+lab4+" so I got to the function");
 alert("The value of Lab 5 is "+lab5+" so I got to the function");
 alert("The value of Lab 6 is "+lab6+" so I got to the function");
 alert("The value of Test 1 is "+test1+" so I got to the function");
 alert("The value of Test 2 is "+test2+" so I got to the function");
 alert("The value of Final is "+test3+" so I got to the function");
 alert("The value of Class Score is "+cp+" so I got to the function");

  document.sum.value = result;
      }     

    if (result >= 405 && result <= 450) {alert("Total Points of "+result+" gives you an A");} 
    else if (result >= 360 && result <= 404) {alert("Total Points of "+result+" gives you an B");}  
    else if (result >= 292 && result <= 359) {alert("Total Points of "+result+" gives you an C");} 
    else if (result >= 247 && result <= 291) {alert("Total Points of "+result+" gives you an D");} 
    else if (result >= 0 && result <= 246) {alert("Total Points of "+result+" gives you an F");} 


        function getTime()
        {
                var now = new Date();
                var h = now.getHours();
                var m = now.getMinutes();
                var s = now.getSeconds();

                m = checkTime(m);
                s = checkTime(s);

                document.getElementById("clock").innerHTML = h + ":" + m + ":" + s;

                setTimeout("getTime()", 1000);
        }

        function checkTime(time)
        {
                if(time<10)
                {
                        time = "0" + time;     
                }

                return time;
        }  

   </SCRIPT>

   </HEAD>
    </TITLE>
     <BODY onload="getTime();">

    <form name="form1">
      Lab #1(10 points):
      <input type="text" name="Lab1Score" size="5"><br> </form>

    <form name="form2">
      Lab #2(10 points):
      <input type="text" name="Lab2Score" size="5"><br> </form>

    <form name="form3">
      Lab #3(10 points):
      <input type="text" name="Lab3Score" size="5"><br> </form>

    <form name="form4">
      Lab #4(20 points):
      <input type="text" name="Lab4Score" size="5"><br> </form>

    <form name="form5">
      Lab #5(20 points):
      <input type="text" name="Lab5Score" size="5"><br> </form>

    <form name="form6">
      Lab #6(30 points):
      <input type="text" name="Lab6Score" size="5"><br> </form>

    <form name="form7">
      Test #1(100 points):
      <input type="text" name="Test1Score" size="5"><br> </form>

    <form name="form8">
      Test #2(100 points):
      <input type="text" name="Test2Score" size="5"><br> </form>

    <form name="form9">
      Test #3(100 points):
      <input type="text" name="Test3Score" size="5"><br> </form>

    <form name="form10">
      Class participation(50 points):
      <input type="text" name="ClassScore" size="5"><br> </form>

  <input type="button" value="Calculate your score" name="add" onClick="do_addition()"><br> </form>

  <p>
  <form name="form11">
    Total Points(450 points):
    <input type="text" name="Total" size="6"><br> </form>

    <input type=reset value=Reset><br> </form> 
<p>The current time is: </p>
<p id='clock'></p> 


</BODY>
</HTML> 

请将您的代码与我的代码进行比较。我已经修复了您的第一部分,即在测试和实验室中计算分数。请对基于时间的测试执行相同的操作

        <html>
            <head>
            <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>



                <script type="text/javascript">

                $(document).ready(function(){

                });

            </script>
        <script type="text/javascript">

        var result=0;

         function do_addition()
             {

              var lab1 = parseFloat(document.forms["form1"]["Lab1Score"].value);
              var lab2 = parseFloat(document.forms["form1"]["Lab2Score"].value);
              var lab3 = parseFloat(document.forms["form1"]["Lab3Score"].value);
              var lab4 = parseFloat(document.forms["form1"]["Lab4Score"].value);
              var lab5 = parseFloat(document.forms["form1"]["Lab5Score"].value);
              var lab6 = parseFloat(document.forms["form1"]["Lab6Score"].value);
              var test1 = parseFloat(document.forms["form1"]["Test1Score"].value);
              var test2 = parseFloat(document.forms["form1"]["Test2Score"].value);
              var test3 = parseFloat(document.forms["form1"]["Test3Score"].value);
              var cp = parseFloat(document.forms["form1"]["ClassScore"].value);
              var sum = (lab1 + lab2 + lab3 + lab4 + lab5 + lab6 + test1 + test2 + test3 + cp); 




            document.forms["form1"]["Total"].value=sum
            result=sum;

          if (result >= 405 && result <= 450) {alert("Total Points of "+result+" gives you an A");} 
            else if (result >= 360 && result <= 404) {alert("Total Points of "+result+" gives you an B");}  
            else if (result >= 292 && result <= 359) {alert("Total Points of "+result+" gives you an C");} 
            else if (result >= 247 && result <= 291) {alert("Total Points of "+result+" gives you an D");} 
            else if (result >= 0 && result <= 246) {alert("Total Points of "+result+" gives you an F");} 

        }     




                function getTime()
                {
                        var now = new Date();
                        var h = now.getHours();
                        var m = now.getMinutes();
                        var s = now.getSeconds();

                        m = checkTime(m);
                        s = checkTime(s);

                        document.getElementById("clock").innerHTML = h + ":" + m + ":" + s;

                        setTimeout("getTime()", 1000);
                }

                function checkTime(time)
                {
                        if(time<10)
                        {
                                time = "0" + time;     
                        }

                        return time;
                }  
        </script>
            <style>

            </style>


            </head>

            <body>
        <form name="form1" >
              Lab #1(10 points):
              <input type="text" id="Lab1Score" name="Lab1Score" size="5"/><br> 


              Lab #2(10 points):
              <input type="text" name="Lab2Score" size="5"><br> 


              Lab #3(10 points):
              <input type="text" name="Lab3Score" size="5"><br> 


              Lab #4(20 points):
              <input type="text" name="Lab4Score" size="5"><br> 


              Lab #5(20 points):
              <input type="text" name="Lab5Score" size="5"><br> 


              Lab #6(30 points):
              <input type="text" name="Lab6Score" size="5"><br> 


              Test #1(100 points):
              <input type="text" name="Test1Score" size="5"><br> 


              Test #2(100 points):
              <input type="text" name="Test2Score" size="5"><br> 


              Test #3(100 points):
              <input type="text" name="Test3Score" size="5"><br> 


              Class participation(50 points):
              <input type="text" name="ClassScore" size="5"><br> 

          <input type="button" value="Calculate your score" name="add" onClick="do_addition();"><br> 


            Total Points(450 points):
            <input type="text" name="Total" size="6"><br> 

            <input type="reset" value="Reset"><br>


        </form> 


        <p>The current time is: </p>
        <p id='clock'></p> <form name="form111">
              Lab #1(10 points):
              <input type="text" name="Lab1Score" size="5"><br> </form>

            <form name="form222">
              Lab #2(10 points):
              <input type="text" name="Lab2Score" size="5"><br> </form>

            <form name="form333">
              Lab #3(10 points):
              <input type="text" name="Lab3Score" size="5"><br> </form>

            <form name="form444">
              Lab #4(20 points):
              <input type="text" name="Lab4Score" size="5"><br> </form>

            <form name="form555">
              Lab #5(20 points):
              <input type="text" name="Lab5Score" size="5"><br> </form>

            <form name="form666">
              Lab #6(30 points):
              <input type="text" name="Lab6Score" size="5"><br> </form>

            <form name="form777">
              Test #1(100 points):
              <input type="text" name="Test1Score" size="5"><br> </form>

            <form name="form888">
              Test #2(100 points):
              <input type="text" name="Test2Score" size="5"><br> </form>

            <form name="form999">
              Test #3(100 points):
              <input type="text" name="Test3Score" size="5"><br> </form>

            <form name="form100">
              Class participation(50 points):
              <input type="text" name="ClassScore" size="5"><br> </form>

          <input type="button" value="Calculate your score" name="add" onClick="do_addition()"><br> </form>

          <p>
          <form name="form111">
            Total Points(450 points):
            <input type="text" name="Total" size="6"><br> </form>

            <input type="reset" value="Reset"><br> </form> 
        <p>The current time is: </p>
        <p id='clock'></p> 


            </body>

        </html>

为什么每次输入都需要单独的表格?我不知道,这是老师告诉我们的方式,但他在很多事情上都错了。应该怎么做?这是Javascript课程的介绍,他一直在教我们错误的东西,错误的标签。爪哇!=javascript。我已经为您更正了,但请小心使用哪一个。