|
||||||
| Javascript Javascript Tutorials and Code |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||||
|
Introduction:-
Here I will show you how to make a simple 'Guess The Number' game. It will do fine as your first game! Solution:- This goes in the <head>:- Code:
<SCRIPT LANGUAGE="JavaScript">
var num = Math.floor(Math.random() * 101);
function guessnum(){
var guess = document.forms['form1'].num.value;
if (guess == num)
{
alert("Great you Guessed! How did you know that?");
}
if (guess < num)
{
alert("No your number is too low!");
}
if (guess > num)
{
alert("No your number is too high");
}
}
</SCRIPT>
Code:
<form name="form1"> Enter a number <input type="text" size=5 maxlength=3 name="num"> <input type="button" onClick="guessnum();" value="Enter"> </form> Code:
var num = Math.floor(Math.random() * 101); A Preview:- Conclusion:- As Always Feedback is welcome and the full source is attached!!
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall ![]() Business Directory | Technology Blog | Windows Help |
| Sponsored Links |
|
|
|
|||||
|
I don't see anything in the code section.
![]() I've seen this before its really cool though and very easy to change the range for the random number. ---------------- Now playing: Disturbed - I'm Alive via FoxyTunes |
|
|||||
|
What code section? You mean the code tags are empty??
Well they are not empty for me :S
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall ![]() Business Directory | Technology Blog | Windows Help |
| Sponsored Links |
|
|
|
|||||
|
Maybe because you did not have enough posts to view the code in the threads?
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall ![]() Business Directory | Technology Blog | Windows Help |
|
|||||
|
Well I don't know... but the code was always there... thats why I asked you... can't understand why you did not see it.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall ![]() Business Directory | Technology Blog | Windows Help |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Creating a card game (multiplaye online with AI).. what do I program this in? | anothersoldier | General Programming | 1 | 07-19-2007 06:46 AM |
| Paying for Links | Chan | Marketing | 26 | 05-02-2007 08:37 PM |
| XBox 360 XNA Game Programming | Jordan | C# Programming | 14 | 09-29-2006 05:10 PM |