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 12 of 12
  1. #1
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question JavaScript Game (Game 1)

    Ok so i want to work on an EASY basic game. As simple as Guess what number... But there are some twist...

    Ok So here is my example...

    (HTML, i know this.)I'm Guessing a number 1-99. What is it?

    (java) Lets say its 66 and they guess 53, have the text rusult be in a pop up window be: Too low!

    (java) Lets say they guess 78, have the text rusult be in a pop up window be: Too high!

    (java) Lets say they guess 100+, have the text rusult be in a pop up window be: Out of range!

    (java)But lets say they guess 66, have a text result be in a pop up window be: You've won!

    (java) I want a text field where you can enter your answer, and it will do the actions above.

    Can anyone code this?
    Thanks for reading!
    Last edited by RSHowat; 07-13-2011 at 01:29 AM.

  • #2
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,742
    Thanks
    41
    Thanked 191 Times in 190 Posts
    I'm wondering if this is an assignment? I'll point you in a direction and help you begin to be able to start the code

    you need to have a pass the typed answer to the function and then analyze the answer in regards to the value. then use if statements to determine an alert and alert the user accordingly.

    even if not assignment need to see some code that you've done

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #3
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Its not, this is personal. Well i barley know java but i can post what i know but its not a whole lot...

  • #4
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,742
    Thanks
    41
    Thanked 191 Times in 190 Posts
    random number
    pass info from filed to function

    then do something to show you are working on developing the analytical section... you will need if statements. also your game2 post (if i remeber the thread correctly will simply be a modification of this

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #5
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    These links should help, can you get on your Yahoo IM so i can get your live help please?

  • #6
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,742
    Thanks
    41
    Thanked 191 Times in 190 Posts
    oh... try again- i blocked... need to let me know before IM'ing me- i didn't know it was anyone "real"

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #7
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    making this public, this is what alykins and I solved, need some error fixing, doesn't seem to be working.

    Code:
    <html>
    <head>
    <title>JSTEST</title>
    <script type="text/javascript">
    function FinNum(guess){
    if (guess == 62) alert ("Your guess is correct!")
    else (guess >= 62) alert ("Your guess is too high!")
    else (guess <= 62) alert ("Your guess is too low!")
    else alert ("Your guess is out of range!")
    </script>
    </head>
    <body>
    <form>
    I'm guessing a number 1-99. What is it?
    <br />
    <input type="input" name="yourGuess" />
    <input
      type="button"
      onclick="FinNum(guess)"
      value="Guess" />
    </form>
    </body>
    </html>

  • #8
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,742
    Thanks
    41
    Thanked 191 Times in 190 Posts
    really? did you not think i would get back online and see this? this is literally the exact "from the top of my head" script i fired through messenger. You need to work with this and figure out the proper syntax's yourself. I am assuming after this post *and I hope* that no one will assist you further until you do some work on your own.

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #9
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    Code:
    onclick="FinNum(guess)"
    Where are you getting guess from in the above line?

    Also, I would convert the number string you pass to the function to a number data type using the Number() object.

    And since you are not submitting the data anywhere, the <form> is actually redundant.

  • #10
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,742
    Thanks
    41
    Thanked 191 Times in 190 Posts
    Quote Originally Posted by bullant View Post
    Code:
    onclick="FinNum(guess)"
    Where are you getting guess from in the above line?

    Also, I would convert the number string you pass to the function to a number data type using the Number() object.
    because this is really incomplete... it incorporates the flow path i have in my head and i gave him this, literally line for line in a chat window as a way to guide him. i didn't fill in all the gaps- i assumed he was going to take this and use it to research how to do it; not just re-post as his code and state that he jointly developed it... i am slightly annoyed right now.

    Edit: and to the OP- you also let out key info i told you to make... i told you to make a var finNum... and i told you it had a purpose... i'm not going to tell you again why i told you to make it and what it was for; but it had to do with my second response to your post
    Last edited by alykins; 07-12-2011 at 11:32 PM.

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #11
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    I was replying to the code posted by the OP (post 7) assuming he/she wrote it.

    I have no way of knowing with certainty who actually wrote that code and who actually wrote it is irrelevant to me.

  • #12
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Just lock this post. I'll mark it as solved. -.-


  •  

    Posting Permissions

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