www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 27

Thread: program will not display

  1. #1
    Join Date
    Sep 2013
    Posts
    26

    program will not display

    I was hoping that someone could please look at this and tell me what I am doing wrong. It will not display any results. I have looked it over but I cannot see why it will not display. Thank You.

    JavaScript>


    Code:
    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";
    		else if (percent >= 90 || <= 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";
    		}
    		else if (percent >= 90 || <= 100)
    			document.gradeForm.Comments.value = "Your Grade: A, Your Precent: + percent";
    		else if (Percent <= 89.9 || >= 80)
    		{
    			document.gradeForm.Comments.value = "Your Grade: B, Your Precent: + percent";
    		}
    		else if else if (Percent <= 89.9 || >= 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";
    		}
    		else if (percent <= 79.9 || >= 70)
    		{
    			document.gradeForm.Comments.value = "Your Grade: C, Your Precent: + percent";
    		}
    		else if (percent <= 79.9 || >= 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";
    		{
    		else if (percent <= 69.9 || >= 60)
    		{
    			document.gradeForm.Comments.value = "Your Grade: D, Your Precent: + percent";
    		}
    		else if (percent <= 69.9 || >= 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 semeseter."/n"
    			Your Grade: F, Your Percent: + percent";
    		}
    	}

    HTML


    Code:
    <!doctype html>
    <html>
    	<head>
    		<title>Grade Reporter</title>
    		<meta charset="utf-8" />
    		<script type="text/javascript" src="sureGrade.js"></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 />
    			<textarea name = "Comments" readonly = "true" value = "Comments" rows = "5" cols = "20"></textarea>
    			<input type="button" value="Check Grade" onclick="check_Grade()" />
    			<br />
    		</form>
    	</body>
    </html>

  2. #2
    Join Date
    Sep 2013
    Posts
    26
    I am wondering if I need to have the (percent >= 90 || <= 100) like this (percent >100) and then the next one (percent >89.9).

  3. #3
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,204
    I suggest that you turn on your javascript console, this will tell you what javascript errors you have and you should be able to solve your homework problems that way

    To help you on your way... you have allot of silly errors, one of which is the ."/n" you are using, that is PHP not javascript, in javascript its a straight forward \n note that its a back slash
    Last edited by \\.\; 10-11-2013 at 06:58 PM.
    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?

  4. #4
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,204
    FYI as a test, I used only the JavaScript console to tell me what errors were in the script, I found them and corrected them and it took less than 5 minutes to get the script functioning.
    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?

  5. #5
    Join Date
    Sep 2013
    Posts
    26

    thanks

    Quote Originally Posted by \\.\ View Post
    FYI as a test, I used only the JavaScript console to tell me what errors were in the script, I found them and corrected them and it took less than 5 minutes to get the script functioning.
    Yes I have that open but to be truthful I most of the time don't understand what the errors are. I will keep working on it though. Thank You

  6. #6
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,204
    OK, lets look at this then.

    You javascript console will tell you what the error is and depending on your browser, the line number.

    Firstly what browser are you using?

    Secondly, what is the first error reported in your console?
    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. #7
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,204
    So we are both on the same page, use this html page in the zip file.

    If you are not using google chrome, I suggest that you grab a copy as it is a pretty useful browser to have and the javascript console is better than others IMHO
    Attached Files Attached Files
    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. #8
    Join Date
    Sep 2013
    Posts
    26
    Ok thanks for taking the time to talk to me. I got chrome and I have the console displayed and it tells me this
    Uncaught SyntaxError: Unexpected token <= on line 16. I have also changed the "new line" to "\n".

  9. #9
    Join Date
    Sep 2013
    Posts
    26
    When I try to run it the console tells me that "check_grade is not defined" Can you explain to me what this means? Please,

  10. #10
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,204
    Ok, one of the first problems with variables and names is that human error in typo's creep in.

    With your <= on line 16, you will see that you are making a logical test against a variable, you have part of this test done correctly, whats missing from the otherside?

    for example
    Code:
    if( someVar1 >= x || someVar2 <=1000){
        // Do something
    }
    The newline character as you have put does not need wrapping in quotes, you use it like this

    Code:
    v = "This is my text\r\n" + 
    "on two lines";
    Remember that \r\n is the character combo for windows based operating systems and \n is for *nix OS's like Linux / Unix systems.

    So...

    1. Check spellings of variables and function names
    2. Check your conditional logic
    3. Check you have used your \r\n or \n properly.
    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?

  11. #11
    Join Date
    Sep 2013
    Posts
    26

    what does this mean

    Quote Originally Posted by \\.\ View Post
    Ok, one of the first problems with variables and names is that human error in typo's creep in.

    With your <= on line 16, you will see that you are making a logical test against a variable, you have part of this test done correctly, whats missing from the otherside?

    for example
    Code:
    if( someVar1 >= x || someVar2 <=1000){
        // Do something
    }
    The newline character as you have put does not need wrapping in quotes, you use it like this

    Code:
    v = "This is my text\r\n" + 
    "on two lines";
    Remember that \r\n is the character combo for windows based operating systems and \n is for *nix OS's like Linux / Unix systems.

    So...

    1. Check spellings of variables and function names
    2. Check your conditional logic
    3. Check you have used your \r\n or \n properly.
    Can you tell me what "Uncaught ReferenceError: check_grade is not defined "? Please
    I did find that percent was spelled wrong and semester but I did not see another one. I also fixed the (percent >= 90 || percent <= 100 && absences <= 2). Am I getting there?

  12. #12
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,204
    Spot on, little things like that cause errors, what you need to do is correct all those errors because you have a few of them. I can tell you that you do have one error that will be reported and it will be on the wrong line number, the clue is that the error is on the line before it.

    Can you try correcting all the other errors and typos then try again.

    Uncaught ReferenceError: check_grade is not defined

    this is not defined because the javascript interpreter wasn't able to make sense of your coding, this shows that you have an error in the function still.

    Unlike HTML markup, javascript isn't robust and can be broken easily.
    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?

  13. #13
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,204
    Can you tell me what line number that error gave, it does help?
    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?

  14. #14
    Join Date
    Sep 2013
    Posts
    26

    reply

    Quote Originally Posted by \\.\ View Post
    Can you tell me what line number that error gave, it does help?
    It was line 68

  15. #15
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,204
    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.
    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