432,414 Members | 1,024 Online
Need help? Post your question and get tips & solutions from a community of 432,414 IT Pros & Developers. It's quick & easy.

# Guess A Number

 P: 17 Hi I am making a basic "guess what number I'm thinking of" script and I cant figure out what I'm doing wrong. When I enter my number it changes it to the right number and says correct. (p.s. kinda new so could be dumb mistake) heres my script: Try to guess what number I'm thinking by typing it in the text box and then clicking the button. (It's between 1 and 5)
Jun 9 '07 #1
7 Replies

 10K+ P: 13,264 Hi I am making a basic "guess what number I'm thinking of" script and I cant figure out what I'm doing wrong. When I enter my number it changes it to the right number and says correct. (p.s. kinda new so could be dumb mistake) heres my script: Try to guess what number I'm thinking by typing it in the text box and then clicking the button. (It's between 1 and 5)
Use == to test for equality not = . Jun 9 '07 #3

 P: 17 Use == to test for equality not = . Thanks guys, A mistype, but could you help me with one more thing? I've edited it a little more so it looks like this [HTML] Try to guess what number I'm thinking by typing it in the text box and then clicking the button. (It's between 1 and 5)
[/HTML] As you may I have noticed I'm trying to make it so that when you type a number not between 1-5 it tells you to type a number in that range. It works good except for if you type a number between 1-5 and its incorrect then it doesnt say anything. thanks Jun 9 '07 #4

 P: 17 Ok so I am making a simple guess a number game (ya know, guess a number I'm thinking of between 1 and 5) And I have one problem, If the number is between 1 and 5 and correct, or isnt between 1 and 5 it says the right message, but if it is between 1 and 5 and is wrong it says nothing. Could I have help? Here is my script: Try to guess what number I'm thinking by typing it in the text box and then clicking the button. (It's between 1 and 5)
Jun 9 '07 #5

 Expert 100+ P: 1,351 Ok so I am making a simple guess a number game (ya know, guess a number I'm thinking of between 1 and 5) And I have one problem, If the number is between 1 and 5 and correct, or isnt between 1 and 5 it says the right message, but if it is between 1 and 5 and is wrong it says nothing. Could I have help? Here is my script: Try to guess what number I'm thinking by typing it in the text box and then clicking the button. (It's between 1 and 5)
this should do the trick: Expand|Select|Wrap|Line Numbers else if  ((document.form1.textbox1.value<0 || document.form1.textbox1.value>5) && document.form1.textbox1.value!=the_answer()) { alert("Sorry, the number was "+the_answer) }   or u can just make it so if its not equal, no matter how low or high, display sorry message. Jun 9 '07 #6

 Expert Mod 15k+ P: 16,027 I've added code tags for you. On line 17, you have added some braces to make the_answer into a function. Jun 11 '07 #7

 Expert Mod 15k+ P: 16,027 Merged both "Guess a Number" threads. Jun 11 '07 #8