我写了个猜字游戏...我把他用窗口输入字母是可以运行的...但我如果把他连去按钮就不行了,每次猜字点那个按纽猜字母都说出错,不知道问题出在那,请各位大大看看,谢谢~~~源码如下~不知道错在那里~
function guessletter(value) {
//sCharacter = oe.value;
sCharacter = value;
//sGuess = prompt("Guess a letter!", ""); //这里是用窗口输入字母..可行的...
sGuess = sCharacter;
if (sGuess == "" || sGuess == null) return;
alert("DEBUG: The index is " + gsWord.indexOf(sGuess));
if (gsWord.indexOf(sGuess) > -1) {
for (i = 0; i < gsWord.length; i++) {
if (gsWord.charAt(i) == sGuess) {
gsDisplayArray[i] = sGuess;
}
}
sDisplay = gsDisplayArray.join("");
if (sDisplay.indexOf("-") == -1 ) {
alert("Well done. You have guessed the word! Yes! It is " + gsWord);
return;
} else {
alert("Well done. Your guess so far is " + sDisplay);
}
} else {
alert("Please try another.");
}
}
function help(){
alert("Please click the A-Z button to guess a letter");
}
[求助]关于一个猜字游戏的问题