|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
||||
|
||||
|
Okay, it's been done before, but what's the big shakes... this was done in the last 30 minutes...
<html> <head> <style type="text/css"> a {color:blue; text-decoration:none;} a:hover {color:blue; text-decoration:none;} </style> <script type="text/javascript"> var letters = "abcdefghijklmnopqrstuvwxyz" var topic = "Movies" var choose = new Array('gone with the wind','the matrix','rush hour','start wars episode two','terminator two') var chosen = new Array() var mychoice = choose[Math.floor(Math.random() * choose.length)] var chosenword = new Array() var chosenword2 = new Array() for (x = 0; x < mychoice.length; x++) { chosenword[x] = mychoice.substr(x,1) if (mychoice.substr(x,1) != " ") { chosenword2[x] = "_" } else { chosenword2[x] = " " } } var wrong = 0 var allowedwrong = 10 var isgame = true function init() { page = "" document.getElementById("topic").innerHTML = topic for (x = 0; x < letters.length; x++) { if (x % 9 == 8) { page += "<br>" } page += "<a href='javascript: chooseme(\"" + letters.substr(x,1) + "\")'>" + letters.substr(x,1) + "</a> " } document.getElementById("letterdisplay").innerHTML = page page = "" for (x = 0; x < chosenword2.length; x++) { page += " " + chosenword2[x] + " " } page += "<br><br>You have " + (allowedwrong - wrong) + " attempts" document.getElementById("display").innerHTML = page } function chooseme(value) { if (isgame) { isfound = false chosen[chosen.length] = value for (x = 0; x < chosen.length; x++) { for (y = 0; y < chosenword.length; y++) { if (chosenword[y] == value) { chosenword2[y] = value isfound = true } } } if (!isfound) { wrong++ if (wrong == allowedwrong) { revealbad() } else { removeme(value) } } else { for (y = 0; y < chosenword2.length; y++) { if (chosenword2[y] != "_") { isanswer = true } else { isanswer = false break } } if (!isanswer) { removeme(value) } else { revealgood() } } } } function removeme(value) { letters =letters.replace(value,"") init() } function revealbad() { isgame = false page = "You're hanged, the answer was<br>" for (x = 0; x < chosenword.length; x++) { page += " " + chosenword[x] + " " } page += "<br><a href='hangman.html'>Play again</a>" document.getElementById("display").innerHTML = page } function revealgood() { isgame = false page = "Well done, the answer was<br>" for (x = 0; x < chosenword.length; x++) { page += " " + chosenword[x] + " " } page += "<br><a href='hangman.html'>Play again</a>" document.getElementById("display").innerHTML = page } </script> </head> <body onLoad='init()'> <center> <h2 id='topic'></h2> <p id='letterdisplay' style='font-size:14pt;'> </p><p> <big>Please select a letter from the above list.</big> </p> <p id='display'> </p> </center> </body> </html> Not Opera this time. |
![]() |
| Viewing: Dev Shed Forums > Other > Dev Shed Lounge > And again.. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|