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 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    need help with this java script!!

    ok i need to develpe a javascript that generates a randome number, then asks you to guess a number, that also gives you hints. ex to high or too low.

    any help is greatly appreciated

  • #2
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72 W. 48' 57" , 41 N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    that sounds suspiciously like a homework assignment
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <script>
    range = 100;
    num = Math.round(Math.random()*range);
    function guess(g) {
    document.guessform.lastguess.value = g;
    document.guessform.guesses.value = parseInt(document.guessform.guesses.value)+1;
    if (g>num) {
    document.guessform.hint.value = "Lower";
    }else if (g<num) {
    document.guessform.hint.value = "Higher";
    }else{
    document.guessform.hint.value = "Correct";
    }
    }
    </script>

    <form name="guessform" onSubmit="guess(this.myguess.value); return false;">
    Guess: <input type="text" name="myguess"><br>
    Hint: <input type="text" name="hint"><br>
    Last Guess: <input type="text" name="lastguess"><br>
    Guesses: <input type="text" name="guesses" value="0"><br>
    <input type="submit" value="Guess">
    </form>


  •  

    Posting Permissions

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