Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2013
    Thanked 0 Times in 0 Posts

    help me fix my coding

    what am i doing wrong my alert pop up is not popping up to calculate my scores please help

              <TITLE>JavaScript Grade Calculator</TITLE>
     <SCRIPT LANGUAGE="javascript">

     function do_addition()
  var lab1, lab2, test1, test2, cp, final;
    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 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 Class Participation is "+ cp+ " so I got to the function")
    alert("The value of Final Exam is "+ final + " so I got to the function")
     if (result >=405 && result<=450) {alert("Total Points of "+result+" gives you an A")}  
     if (result >=360 && result<=404) {alert("Total Points of "+result+" gives you an B")}  
     if (result >=292 && result<=359) {alert("Total Points of "+result+" gives you an C")}  
     if (result >=247 && result<=291) {alert("Total Points of "+result+" gives you an D")}  
     if (result >=0 && result<=246) {alert("Total Points of "+result+" gives you an F")}  
    <center><form name="form1">
     Lab #1 (30 points):
      	    <input type="text" name="Lab1Score" size="5"><br>
     Lab #2 (70 points):
      	    <input type="text" name="Lab2Score" 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>
     Class Participation (50 points):
      	    <input type="text" name="CPScore" size="5"><br>
     Final Exam(100 points):
      	    <input type="text" name="FinalScore" size="5"><br>
        <input type="button" value="Calculate your score" name="add" onClick="do_addition()"><br>
      Total Points (450):    
      <input type="text" name="Total" size="6"><br>
      <input type=reset value=Reset><br>

  2. #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,699 Times in 2,675 Posts
    When I copy your code I find additional ? characters in places. I think you have been using a word processor rather than a text editor to compose your code.

    Assigning a name to a form is obsolete. Use an id instead.

    It is your responsibility to die() if necessary….. - PHP Manual

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


Posting Permissions

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