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

    newbie needing help (simple i hope)

    Hello everyone. Im a newbie at javascript and in need of some help.
    I read the rules, and i think i can post this i hope.
    Yes it is for school, but at least i wrote it myself.
    lol
    Anyway its a simple program, but im stumped has in why it doesnt work.
    This is what happens.
    You open the page a box pops up and askes, type in a number 1 for pass,
    or 2 for fail ok thats all good.
    But its suppose to stop after asking a few times.
    whats happens is it just keeps asking for more info.
    it doesnt end, even if you click on cancel it just askes again.
    And i cant even close the browser either
    I hope that i explained myself well for you, enough to get some help on it. because im starting to pull my hair out on why i cant get it to work.
    did i write it totally wrong ....?is it something simple that im not seeing.
    excuse my english im learning quickly.
    thanks for any help you can provide me with


    <html>
    <head>
    <title>why why wont it work</title>
    <script type = "text/javascript">
    <!--
    var passes=0,
    var failures=0,
    var student=0,
    result;

    while (student<=10){
    result=window.prompt("enter result"
    + "(1=pass,2=fail)","1");

    while (result !="1" || result !="2")
    result = window.prompt(
    "incorrect result. please enter 1 for pass"
    +"or 2 for fail", "1");
    }
    if (result== "1")
    passes = passes +1;
    else
    failure=failures +1;

    student=student+1;

    document.writeln("<h1>examination results</h1>");
    document.writeln(
    "passed:"+passes+"<br/>failed:"+failures);
    if (passes >8)
    document.writeln("<br/raise tutition");
    //-->
    </script>
    </head>
    <body>
    <p>click refresh(or reload) to run the script again</p>
    </body>
    </html>

  • #2
    New Coder
    Join Date
    Jun 2006
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    first off <script type = "text/javascript"> needs to be changed to
    <script language="JavaScript" > so browser can read the java script

  • #3
    New Coder
    Join Date
    Jun 2006
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This code looks completely wrong , i dont even think this is javascript. Read a book on javascript or google javascript. The way you declared your variables is wrong also..

  • #4
    New to the CF scene
    Join Date
    May 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, but thats not gonna change anything .
    Your way may be the proper way, but the browser picks up the javascript code fine the way i did it.
    Even my prof said that it was ..."ook i guess" lol .

    Its something in the code itself thats messing it up.

    I have spent hours trying to figure it out and it took me way less time to write it.lol. and istill cant figure it out
    I looked everything over and over .

    if i dont figure it out by tomorrow or someone figures it out for me.
    im just gonna hand it in that way lol and hopefully at least get a decent mark for my attempt at writing it.

    but thanks anyway for trying to help me.

  • #5
    New to the CF scene
    Join Date
    May 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh its javascript all right. or my teacher is gone thru the roof. he kinda looks it.
    Maybe thats it, my variables are wrong. lol but i went thru them so many times wrote them differently. nothing.

    Id say the book i was given but the rules dont allow advertisment.

    When i figure it out ill post my findings on here so other can have a hint on whats wrong and whats not.

    Thanks again anyway for you help both of you.


  •  

    Posting Permissions

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