Results 1 to 12 of 12

Thread: Why doesn't this work???

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Location
    New York
    Posts
    679

    Why doesn't this work???

    Please take a look at this script, and see if anyone can explain why it will not work on my INtranet page...It loads fine, but when I try to start it...I get "Error on Page"

    Code:
    <HEAD>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    msg = new Array("Practicing with your typing can greatly help your overall computer skills.",
    "A new computer is sold in the US every hour!",
    "When do birds migrate from North to South?",
    "Perplexing phrases, like this one, are tougher to type.")
    word = 10
    function m() {
    msg = new Array("Practicing with your typing can greatly help your overall computer skills.",
    "A new computer is sold in the US every hour!",
    "When do birds migrate from North to South?",
    "Perplexing phrases, like this one, are tough to type.")
    word = 10
    }
    function e() {
    msg = new Array("If you can correctly, and quickly, type this perplexing sentence, you are one superb typist!",
    "You are one superb typist if you can correctly, and quickly, type this long phrase.",
    "I believe you're a good typist, so I believe you will correctly copy this statement!",
    "Because this is not a fairly simple phrase, could you swiftly, and precisely, copy it?")
    word = 15
    }
    function s() {
    msg = new Array("Computers are the medium of the future.",
    "Can you type this phrase rather quickly?",
    "Who is the President of the US?",
    "I believe that you can type well!")
    word = 7
    }
    function beginIt() {
    randNum = Math.floor((Math.random() * 10)) % 4
    msgType = msg[randNum]
    day = new Date();
    startType = day.getTime();
    document.theForm.given.value = msgType
    document.theForm.typed.focus();
    document.theForm.typed.select();
    }
    function cheat() {
    alert("You can not change that!");
    document.theForm.typed.focus();
    }
    function stopIt() {
    dayTwo = new Date();
    endType = dayTwo.getTime();
    totalTime = ((endType - startType) / 1000)
    spd = Math.round((word/totalTime) * 60)
    if (document.theForm.typed.value == document.theForm.given.value) {
    alert("\nYou typed a " + word + " word sentence in " 
    + totalTime + " seconds, a speed of about " + spd + " words per minute!")
    }
    else {
    alert("You made an error, but typed at a speed of " + spd + " words per minute.")
       }
    }
    // End -->
    </SCRIPT>
    </HEAD>
    <BODY>
    <CENTER>
    <FORM name="theForm">
    <TABLE BORDER=3 CELLSPACING=0 CELLPADDING=0>
    <TR>
    <TD>Are you a....</TD>
    <TD align=center><input type=radio name="sme" value="Beginner" onClick="s()" checked>Beginner
    <input type=radio name="sme" value="Novice" onClick="m()">Novice
    <input type=radio name="sme" value="Expert" onClick="e()">Expert</TD>
    </TR>
    <TR><TD colspan=2><BR>
    <center><input type=button value="Start Typing Test" name="start" onClick="beginIt()"></center><P>
    <textarea name="given" cols=53 rows=3 wrap=on onFocus="cheat()"></textarea></TD>
    </TR>
    <TR><TD colspan=2><center><input type=text name="typed" size=45>
    <input type=button value="DONE"  name="stop"  onClick="stopIt()"></center></TD>
    </TR>
    </TABLE></FORM>
    </CENTER>]
    Thank you....

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    your missing alot of ;'s
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Location
    New York
    Posts
    679
    I don't understand what you mean??

    What am I missing?

  4. #4
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Semi-colons aren't mandatory in JS - you can use newlines instead.

    I don't get any errors on that page, what is the error message?

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Location
    New York
    Posts
    679
    RickBull,

    All I am getting is "Error on Page"!!!

    I do not understand....could it be because I am working on an Intranet site??

    If you have any suggestions, I am willing to listen

    Thank you.

  6. #6
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    But doesn't it say "error on line xxx", and then some brief description like "object doesn't support this method", or something? The only time I get an error is if I press "done" before I press "start...". Which browser are you testing with?

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Is it on line 45, "starttype is undefined" ?

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Location
    New York
    Posts
    679
    Mendhak,

    Do you know how I am supposed to fix that?

  9. #9
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Try putting var startType; at the start of the script. How come I'm not getting this error though?! Maybe my browser respects me and not Mendhak

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by Rick Bull
    Try putting var startType; at the start of the script. How come I'm not getting this error though?! Maybe my browser respects me and not Mendhak
    Maybe the browser just likes playing tricks with me... It worked fine for me a few times after which I got that error.

    (I think I did it by clicking on the done button several times in a frantic frenzy)

  11. #11
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Haha, maybe it just got annoyed at you for keep clicking him so much then?

  12. #12
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    I guess it's got Artificial Intelligence

Posting Permissions

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



Click Here to Expand Forum to Full Width