我想問一下Javascript中的表單。再次顯示錶單?
我想做一個遊戲,用戶輸入正確的單詞,然後警告消息將出現這個正確的單詞。當用戶確認第一個單詞時,程序將顯示另一個單詞(待更正)。但是我面對的問題是我無法讓表格再次顯示以繼續比賽。
我用:
var d = document.getElementById("form1"); d.style.visibility = "visible";
,但它不工作!
這是我的代碼:
<head>
<title>Word Decoder</title>
<script type="text/javascript">
function checkWord(word, score)
{
var ok = words[score].valueOf();
var ok1 = document.getElementById("wordid");
if(ok1.value == ok)
{
score ++;
alert("Correct, your score is: " + score);
var d = document.getElementById("form1");
d.style.visibility = "visible";
return false;
}
else
{
alert("Wrong Spelling");
return false;
}
}
</script>
</head>
<body>
<script type="text/javascript">
var words = new Array ("apple", "orange", "banana", "manago", "table");
var reWords = new Array ("alpep", "ergano", "aaabnn", "goamna", "lbeat");
var count = 0;
var score = 0;
"</br>";
</script>
<form id="form1">
<br>
<dir id="displayForm"
style="position: relative;
visibility: visible;
display: block">
<h3><b> <script> document.write(reWords[score]);</script> </b></h3>
<br>
Enter the correct word: <input type="text" value="" id="wordid"/>
<input type="submit"
value="Check Answer ??"
onclick="return checkWord(wordid, score);" />
</dir>
</form>
</body>
還是那句話:我希望遊戲會顯示一個炒字,用戶必須解讀爲移動到另一個字的字。問題是我無法再次顯示錶單以使用戶解讀第二,第三等詞語。
d.style.display =「block」 >>我用這種方式,但它不起作用.. – user289227 2010-03-09 08:00:45
As @ Tracker1說,你怎麼隱藏窗體? – Jeremy 2010-03-09 12:18:41