Display the form again ?

Posted by noralain on Stack Overflow See other posts from Stack Overflow or by noralain
Published on 2010-03-08T23:07:24Z Indexed on 2010/03/08 23:21 UTC
Read the original article Hit count: 386

Filed under:
|

Hi all,

I want to ask about the form in javascript ..

I want to do a game that the user enter the correct word, then alert message will apeared for correct word.. When the user do the first word correctly, the program will display another word (to be corrected) .. but the problem which i faced that i can't make the form display again to continue play the game ..

i used :

var d = document.getElementById("form1"); d.style.visibility = "visible";

but it doesn't work !!

This is my code:

    <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>

Can help me to solve the problem? Again: I want the game will display a scrambled word and the user must unscrambled the word to move to the other word. The problem is i can't display the form again to make the user unscrambled the second, third ..etc words..

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about form