CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Help with Javascript Homework

  1. #1
    Join Date
    Jul 2010

    Help with Javascript Homework

    I have been struggling with this code for three days. My teacher wants the layout to be like it is and there is a way to make it work that way but I am at a loss as to how to do it. She wants the function to be in the heading and the input for the function to be in the body and the button is supposed to calculate the Final Course Grade. I've tried two debuggers (firefox and PSpad) and they both get stuck on the Name not being defined. There are other errors to be sure.

      <title> Find Your Grade Here!!!!one!eleven! </title>
        <script type="text/javascript">
          // Assumes: Each box has a numerical value
          // Results: Calculates Final Grade and gives a message with Name 
          // and Ginal Pourse Frade.
          function GPA (HomeworkAverage,LabAverage, MidtermAverage,FinalExamGrade)
    	       var FinalCourseGrade =(HomeworkAverage*0.25 +LabAverage*0.20 + 
              MidtermAverage*0.25 +FinalExamGrade*0.30);
              var Name = document.getElementByID('Nbox');
              message = "Hello " + Name + ", " <br>
    				 "According to your input, " <br>
    				 "Your Homework Average Was: " + HomeworkAverage + " "<br>
    				 "Your Lab Average Was: " + LabAverage + " "<br>
    				 "Your Midterm Average Was: " + MidtermAverage + " "<br>
    				 "Your Final Exam Grade Was: " + FinalExamGrade + " "<br>
    				 "Therefore, Your Final Course Grade is: " + FinalCourseGrade  + " ";
    		    return message;
    <h2 ALIGN=CENTER>This neat thing will help you find out your grade point
        Enter Name:
        <input type="text" id="Nbox" size="25" value="Johnathon Reinier" />
        Enter Homework Average:
        <input type="text" id="HWAbox" size="4" value="98" />
        Enter Lab Average:
        <input type="text" id="LAbox" size="4" value="97" />
        Enter Midterm Average:
        <input type="text" id="MAbox" size="4" value="87" />
        Enter Final Exam Grade:
        <input type="text" id="FEbox" size="4" value="105" />
        <input type="button" value="FinalCourseGrade"
    	     onclick= Name = document.getElementbyId('Nbox').value;
                             Name = parseFloat(Name);
    		         HomeworkAverage =  document.getElementbyId('HWAbox').value;
    			 HomeworkAverage = parseFloat(HomeworkAverage);
    			 LabAverage = document.getElementbyId('LAbox').value;
    			 LabAverage = parseFloat(LabAverage);
    			 MidtermAverage = document.getElementbyId('MAbox').value;
    			 MidtermAverage = parseFloat(MidtermAverage);
    			 FinalExamGrade = document.getElementbyId('FEbox').value;
    			 FinalExamGrade = parsefFloat(FinalExamGrade);
    			 Function GPA (HomeworkAverage, LabAverage, MidtermAverage, FinalExamGrade);
    			 FinalCourseGrade = parseFloat(FinalCourseGrade);/>

  2. #2
    Join Date
    Jul 2010

    Re: Help with Javascript Homework

    Oops wrong place for this post... will correct this in a few seconds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)