So I'm having some problems with my code here. and I'm not sure whats wrong. Im following a textbook on how to do it and this is basically the same format that they have for a random number function. Any feedback is appreciated.

        <title> Grades </title>
        <script type="text/javscript">

            function Grader() 
                var am1=parseFloat(document.getElementById('homework').value*0.25);
                var am2=parseFloat(document.getElementById('labs').value*0.20);
                var am3=parseFloat(document.getElementById('midterm').value*0.25);
                var am4=parseFloat(document.getElementById('final').value*0.30);
                var hw=homework*am1;
                var lbs=labs*am2;
                var mt=midterm*am3;
                var fe=finals*am4;
                var total = am1+am2+am3+am4;

                document.getElementById('outputDiv').innerHTML='Your final grade is ' + total;

      <h3>Enter your grade for each section</h3>


      <td><input type="text" id="homework" size=2 value=""></td>

      <td><input type="text" id="labs" size=2 value=""></td>

      <td><input type="text" id="midterm" size=2 value=""></td>

      <td>Final Exam</td>
      <td><input type="text" id="finals" size=2 value=""></td>

        <input type="button" value="Calculate Grade" 

        <div id="outputDiv"></div>


You have a typo in your script tag: text/javscript should be text/javascript. (Missing the second 'a' in 'javascript'.)

You also have a typo in your function Grader() ('finals' vs 'final'). The line that gets the value of the Final Exam reads:

var am4=parseFloat(document.getElementById('final').value*0.30);

but it should be:

var am4=parseFloat(document.getElementById('finals').value*0.30);

Fix those two issues and it should work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.