Results 1 to 4 of 4

Thread: Nothing much.

  1. #1
    Join Date
    Mar 2003
    Location
    Canada...In an Igloo.
    Posts
    149

    Nothing much.

    This is my hang man script... Not totally done yet.

    <script>
    var Spelling=new Array("que bec","ont ario","mani toba","Brit ish","NewF oundLand");
    var rNum=eval(Math.round(Math.random()*(4-1))+eval(1));
    var word1=Spelling[rNum];
    // -------------------------------FUNCTION STARTGAME - STARTS THE GAME AND OUTPUTS STARS-SPACES ETC!
    function STARTGAME() {

    var starword=""
    var space="";
    for (var i=0; i<word1.length; i=i+1) {
    if (word1.charAt(i) == " ") {
    space=" ";
    starword=starword+space;
    space="";
    } else {
    starword=starword+"*"
    space="";
    } //END IF
    } //END FOR
    document.HangManGame.KeyWord.value=starword;
    } //END FUNCTION


    // ----------------------------------------------FUNCTION TRYLETTER - TRIES TO SEE IF THE LETTER IS IN THE WORD.
    function TRYLETTER() {
    var Trylett=document.HangManGame.YourGuess.value;
    alert(word1);

    for (var i=0; i<word1.length; i=i+1) {
    if (word1.charAt(i) == Trylett) {
    KeyWord=
    alert("FOUND")
    } else {
    alert("NOT FOUND")
    } // END IF
    } // END FOR
    } // END FUNCTION


    //------------------FUNCTION SOLVEIT - IF THE USER TRIES TO SOLVE IT - IT CHECKS TO SEE IF IT IS EQUALS.
    function SOLVEIT() {
    }

    </script>

    <img src="6.jpg" name="BuzzLightYear">
    <form name="HangManGame">

    <P>
    Mystery Word: <input type="textbox" name="KeyWord"><P>
    Your Guess: <input type="textbox" name="YourGuess"> <input type="button" value="Try Letter" onClick="TRYLETTER()"><P>
    Status: <input type="textbox" name="Status"><P>
    <input type="textbox" name="SolveWord"> <input type="button" value="Solve It Now!" onClick=" randint()"><P>
    <input type="button" value="Start Game" onClick="STARTGAME()">
    </form>
    This is my signature. Nice, eh?

  2. #2
    Place it in the PHP BBCode. It makes it 10x easier to read!

  3. #3
    Join Date
    Mar 2003
    Location
    Canada...In an Igloo.
    Posts
    149
    PHP Code:
    <script>
    var 
    Spelling=new Array("quebec","ontario","manitoba","british columbia","newfoundLand");
    var 
    rNum=eval(Math.round(Math.random()*(4-1))+eval(1));
    var 
    word1=Spelling[rNum];
    var 
    starword="";
    // -------------------------------FUNCTION STARTGAME - STARTS THE GAME AND OUTPUTS STARS-SPACES ETC!

    function STARTGAME() {

    var 
    space="";
    for (var 
    i=0i<word1.lengthi=i+1) {
    if (
    word1.charAt(i) == " ") {
    space=" ";
    starword=starword+space;
    space="";
    } else {
    starword=starword+"*"
    space="";
    }  
    //END IF
    //END FOR
    document.HangManGame.KeyWord.value=starword;
    }  
    //END FUNCTION


    // ----------------------------------------------FUNCTION TRYLETTER - TRIES TO SEE IF THE LETTER IS IN THE WORD.

    function TRYLETTER() {
    var 
    hittmiss="MISS";
    var 
    Trylett=document.HangManGame.YourGuess.value;
    //var Trylett=Trylet.toLowerCase();
    alert(Trylett);
    //alert(word1);
    for (var i=0i<word1.lengthi=i+1) {
    if (
    word1.charAt(i) == Trylett) {
    starword=starword.substring(0,i)+Trylett+starword.substring(i+1,starword.length);
    document.HangManGame.KeyWord.value=starword;
    hittmiss="HIT";
    } else {


    }  
    // END IF
    // END FOR

    document.HangManGame.Status.value=hittmiss;
    // END FUNCTION


    //------------------FUNCTION SOLVEIT - IF THE USER TRIES TO SOLVE IT - IT CHECKS TO SEE IF IT IS EQUALS.
    function SOLVEIT() {
    if (
    document.HangManGame.SolveWord.value == word1) {
    alert("You won the game!");
    } else {
    alert("You lost");
    }

    }

    </script>

    <img src="6.jpg" name="BuzzLightYear">
    <form name="HangManGame">

    <P>
    <table border=1>
    <tr><td>Mystery Word: <input type="textbox" name="KeyWord"></td><td></td></tr>
    <tr><td>Your Guess:  <input type="textbox" name="YourGuess"></td><td><input type="button" value="Try Letter" onClick="TRYLETTER()"></td></tr><P>
    <tr><td>Status: <input type="textbox" name="Status"></td><td></td></tr>
    <tr><td><input type="textbox" name="SolveWord"></td><td><input type="button" value="Solve It Now!" onClick="SOLVEIT()"></td></tr>
    <tr><td><input type="button" value="Start Game" onClick="STARTGAME()"></td><td></td></tr>
    </table>
    </form> 
    This is my signature. Nice, eh?

  4. #4
    Join Date
    Jul 2003
    Location
    Kuwait
    Posts
    5,099
    Are you just posting it here for posterity, or you need help with something?
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

  5. Newsletters

    Subscribe Now & Get The WHT Quick Start Guide!

Related Posts from theWHIR.com

Posting Permissions

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