Welcome Guest [Log In] [Register]
This board has been archived and is no longer accepting new questions. If you have a support question for your ZetaBoard, please visit us at the new support board. Registration is free and easy.


Visit the NEW ZetaBoards Support forum!

Username:   Password:
Add Reply
How do I make this random?
Topic Started: Jun 21 2008, 12:08 PM (623 Views)
slayer766
Member
[ * ]
Try this:

Code:
 
<script type="text/javascript">
var x=prompt("Enter a number between 1 and 10:","");
Guess_NUM = Math.floor(Math.random()*10+1);

if(x > 10){
alert("Too high");
}
if(x < 1){
alert("Too low");
}
if(!x.match(/^\d+$/i)){
alert("Not a number");
}
if(x == Guess_NUM){
alert("Correct!");
}
else if(x>=1&&x<=10){
alert("Try again\nCorrect answer: "+Guess_NUM);
}
</script>
Offline Profile Quote Post Goto Top
 
Thunder
Member Avatar
Thunder
[ *  *  * ]
Thank you, thank you!!!
Offline Profile Quote Post Goto Top
 
Thunder
Member Avatar
Thunder
[ *  *  * ]
Wait, it only works if I put it on the main page. If I put it onto a created webpage (by search) the number between 1 and 10 that I type in don't work, because the alert say that it's not a number.
Offline Profile Quote Post Goto Top
 
RyuraGS
Member Avatar
Member
[ *  *  * ]
Thunder
Jul 9 2008, 08:43 PM
Wait, it only works if I put it on the main page. If I put it onto a created webpage (by search) the number between 1 and 10 that I type in don't work, because the alert say that it's not a number.
There's no reason that should happen. Example page?
Offline Profile Quote Post Goto Top
 
Thunder
Member Avatar
Thunder
[ *  *  * ]
http://s1.zetaboards.com/Thunders_Test_Board/pages/number-game/ this is where it doesn't work.
Offline Profile Quote Post Goto Top
 
slayer766
Member
[ * ]
Don't place the code in the webpage area as it changes some characters for some reason...
Offline Profile Quote Post Goto Top
 
Thunder
Member Avatar
Thunder
[ *  *  * ]
Um...Ok.
Offline Profile Quote Post Goto Top
 
slayer766
Member
[ * ]
It's a bug for Zetaboards I believe for the webpage when putting scripts in it, as the code looks like this:

Code:
 
<script type="text/javascript">var x=prompt("Enter a number between 1 and 10:","");Guess_NUM = Math.floor(Math.random()*10+1);if(x > 10){alert("Too high");}if(x < 1){alert("Too low");}if(!x.match(/^\d+$/i)){alert("Not a number");}if(x == Guess_NUM){alert("Correct!");}else if(x>=1&&x<=10){alert("Try again\nCorrect answer: "+Guess_NUM);}</script>

That's not what my code looks like...
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · jQuery Help · Next Topic »
Add Reply