www.webdeveloper.com
Results 1 to 2 of 2

Thread: Word game

  1. #1
    Join Date
    Feb 2010
    Posts
    2

    Word game

    Hello again,

    I just wanted to thank all the people on here who have been helping me with JavaScript. I just had one more question.. Here is a part of the code so far.

    function processGuess(){
    var newLetters = /^[^A-Za-z]$/;
    var lastLetters = document.getElementById("putGuessHere");
    var finalGuess = lastLetters.value.toLowerCase();
    if (newLetters.test(finalGuess)) {
    document.getElementById("noNumbers").innerHTML = "you have to put in letters";
    }
    else if (wrongGuesses == finalGuess) {
    alert("you already guessed that letter")
    }
    clearTimeout (guessTimeout);
    guessTimeout = setTimeout("outOfTime();" , 5000);
    }

    <body onresize="setImageSize()">
    <p>
    <form action="">
    <input type="button" id="newGame" value="Click Here To Start Game!" onclick="startGame();">
    <br/>
    <img id="thePicture" border="0" src="Images/Hangman0.jpg" width="300" height="300" alt="The hangman image">
    <br/>
    Type Your Next Guess Here:
    <input type="text" id="putGuessHere">
    <br/>
    <input type="button" id="checkGuess" value="Check my Guess!" onclick="processGuess();">
    <br/>
    <br/>
    </p>
    </form>

    <p id="secretWordDisplay" style="font-size:32pt;">
    </p>
    Wrong Guesses:
    <p id="wrongGuesses" style="font-size:32pt;">
    </p>
    <p id="noNumbers" style="font-size:32pt;">
    </p>
    <p id="bestScore">
    </p>
    <p>
    This web page has been tested in LIST THE BROWSER(S) HERE!!!!!
    </p>
    </body>

    basically I have most of it working.. so far what happens is when the game starts a user chooses a word. for example "hello". After he/she types that in it becomes **** stars. The problem that i'm having is when the user inputs a letter for example "h" in the guess field and presses the guess button nothing happens. and I also need it to need the wrong guesses to go into a different paragraph or field. If anyone could help me with this I would really appreciate it. Thanks again!!

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,355

    Lightbulb Consider this ...

    If you do a searc of this forum with 'hangman'
    you can see a bunch of different examples on how to
    create and solve your particular problem.

    Compare your code to those. You might come up with an improved version.

    Good Luck!

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