www.webdeveloper.com
Page 2 of 2 FirstFirst 12
Results 16 to 27 of 27

Thread: program will not display

  1. #16
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,414
    I note that the error says check_grade() and your function is check_Grade(), did you change the function name?
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  2. #17
    Join Date
    Sep 2013
    Posts
    26
    Quote Originally Posted by \\.\ View Post
    Doesn't make any sense, are you using the version I uploaded?

    It might be better to copy and paste exactly as your code is in your editor to see if you have made any other changes that will affect the line number error. Remember to use the CODE tags when posting.

    I will be heading off to bed very soon, if you don't get a response tonight, I will tomorrow.
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <script>
    function check_grade()
    {
    	 var percent = document.gradeForm.percent.value;
    	 var percent = parseFloat(percent);
    	 var absences = document.gradeForm.absences.value;
    	 var absences = parseInt(absences);
    	
    		If (absences >= 5) 
    		{
    			document.gradeForm.comments.value = "You have an F because of excessive absentees";
    		}
    	    If (percent >= 90 || percent <= 100 && absences <= 2)
    		{
    			document.gradeForm.comments.value = "You have gained 3% to your percent for having few absences. + \n"
    			"Your Grade: A, Your Percent: + percent * 0.3";
    		}
    		If (percent >= 90 || percent <= 100)
    			document.gradeForm.comments.value = "Your Grade: A, Your Percent: + percent";
    		If (percent <= 89.9 || percent  >= 80)
    		{
    			document.gradeForm.comments.value = "Your Grade: B, Your percent: + percent";
    		}
    		If (percent <= 89.9 || percent >= 80 && absences <= 2)
    		{
    			document.gradeForm.comments.value = "You have gained 3% to your percent for having few absences. + \n"
    			"Your Grade: B, Your Percent: + percent * 0.3";
    		}
    		If (percent <= 79.9 || percent >= 70)
    		{
    			document.gradeForm.comments.value = "Your Grade: C, Your Percent: + percent";
    		}
    		If (percent <= 79.9 || percent >= 70 && absences <= 2)
    		{
    			document.gradeForm.comments.value = "You have gained 3% to your percent for having few absences. + \n"
    			"Your Grade: C, Your Percent: + percent * 0.3";
    		{
    		If (percent <= 69.9 || percent >= 60)
    		{
    			document.gradeForm.comments.value = "Your Grade: D, Your Percent: + percent";
    		}
    		If (percent <= 69.9 || percent >= 60 && absences <= 2)
    		{
    			document.gradeForm.comments.value = "You have gained 3% to your percent for having few absences. + \n"
    			"Your Grade: D, Your Percent: + percent * 0.3";
    		}
    		Else 
    		{
    			document.gradeForm.comments.value = "I am sorry you have fail this semester. + \n"
    			"Your Grade: F, Your Percent: + percent";
    		}
    		}
    </script>
    </head>
    
    <body>		
    <form name="gradeForm" action="#">
       <label for="absences">How many absences do you have?: </label><br />
       <input type="text" name="absences" /><br />
       <label for="percent">What is your grade percent? </label><br />
       <input type="text" name="percent" /><br />
       <input type="button" value="Check Grade" id="checkGradeButton"  onclick="check_grade()" />
       <label for="comments">COMMENTS: </label>
       <textarea id="comments"></textarea>
    </form>
    </body>
    </html>

  3. #18
    Join Date
    Sep 2013
    Posts
    26
    yes i was just stabbing at things

  4. #19
    Join Date
    Sep 2013
    Posts
    26
    it now gives me these

    Uncaught SyntaxError: Unexpected end of input grades.html:1
    Uncaught ReferenceError: check_grade is not defined grades.html:67

  5. #20
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,414
    Looking at the code

    This is wrong...

    Code:
    ces. + \n"
    it should be

    Code:
    ces.\n" +
    because in javascript you are adding a further element to the end of an existing string which in this case is a string.


    If and Else is fine if you were writing in VBscript but we aint!

    You need to put back all the

    Code:
    if( ...){
    // do something
    
    }else if(...
    because javascript uses lower case if , else if conditionals.

    so putting all the if else's properly, on my javascript console I get

    Uncaught SyntaxError: Unexpected token else grades.html:43 on line 43 BUT !!! that is not where the error is, it is actually the line above it.

    So without changing the line numbers, just the elements that need putting back in to play, you should get the same error. Can you spot it?

    You still have code problems but we will discuss those in a bit...
    Last edited by \\.\; 10-13-2013 at 04:21 AM.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  6. #21
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,414
    Quote Originally Posted by plat View Post
    yes i was just stabbing at things
    Stabbing at things can sometimes lead to bigger problems, it is always best to look at the error message and read what line the error is reported on as that is you biggest clue.

    Syntax Errors are what I have posted about, see If Else Vs if else comment.

    Reference Errors are relating to something you have referred to in your script that generally do not exist like check_Grades() Vs check_grades()
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  7. #22
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,414
    DING DING....

    Did you get your script sorted in the end?

    Did you understand what was covered on sitepoint?
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  8. #23
    Join Date
    Sep 2013
    Posts
    26
    Quote Originally Posted by \\.\ View Post
    DING DING....

    Did you get your script sorted in the end?

    Did you understand what was covered on sitepoint?
    I am starting to understand. I thought I could just fly through that program but I was really wrong. I really do appreciate all of you trying to explain all my mistakes to me. Thank You

  9. #24
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,414
    Thats great that you are learning, it is like a curve, the more you do it the more easier it gets and the quicker you can put code together and the amount of time it takes then become almost intuitive.

    So how much have you done so far? Any more errors?
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  10. #25
    Join Date
    Sep 2013
    Posts
    26

    reply

    Quote Originally Posted by \\.\ View Post
    Thats great that you are learning, it is like a curve, the more you do it the more easier it gets and the quicker you can put code together and the amount of time it takes then become almost intuitive.

    So how much have you done so far? Any more errors?
    I or should I say we have it ti where it works and adds the percent for "A" but then after that it will not add the percent. All the code looks just alike so I can't figure out what the problem is.

  11. #26
    Join Date
    Sep 2013
    Posts
    26
    Never mind I got it now. Thank You

  12. #27
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,414
    When doing a check on a value, it is best to do it like...

    Code:
    if( checkVariable>=lowerNumber && checkVariable<=upperNumber){
        // do something
    }else if(...
    If you are checking two variables then something like this is needed.

    Code:
    if( (checkVariable>=lowerNumber && checkVariable<=upperNumber) && someOtherVariable<=numberValue){
        // do something
    }else if(...
    what that does is ensures that the checks in the ()'s happens first, this is precedence and if you look it up for programming, you will see that it doesn't matter what language you use, Java, PHP, C, fortran, cobol, pascal or JavaScript, precedence will be the same.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles