How to fix ‘alert’ that affects inner.html display?
A game I’m working on has several rounds of play. After each round an alert shows ‘Correct’ or ‘Incorrect.’ Then a cumulative score is displayed in a separate div using inner.html. All of that works well. So I took out the alert. Now, when the round is over the screen flashes to the next round without displaying the cumulative score. Possibly the cumulative score is displayed momentarily, but that does no good. How do I fix this?
Thanks.
I tried the suggestion both in the function only, and then throughout the code. Neither worked...display still flashes to the next round of the game without showing the current score. When I reactivated the alert, then the current score was shown. I watched carefully...the 'flash' seems to go from the correct display to an instantaneous white screen and then to the correct display again. Maybe that's a clue? Any other thoughts?
Below is the code after trying several different ways to do as you suggested. My guess is that I don't understand how to incorporate it. Could you mark up the code the right way?
Re. using <form>...there is one use of it in the game portion itself, but not in the div where the score summary is placed.
I'm in over my head...hope you guys can help me out!
-------------------------------
function showScore()
{if (success==1 && games<playGames) {msg0=msg1; }
else if (success==-1 && games<playGames) {msg0=msg2; }
// setTimeout("func2()",1000);
//alert(msg0);
func2();
}
function func2()
{setTimeout("func2()",1000);
var gg="Rounds";
if (games==1) {gg="Round"}
var ww="Wins";
if (wins==1) {ww="Win"}
score = "<center><table border=3 bgcolor=#B4FBAA cellpadding=1 cellspacing=1 height=34 width=536><tbody valign=middle align=center><tr><td><font face='Verdana' size='2'>"+games+" "+gg+" played, "+wins+" "+ww+". You've earned "+poynts+" out of a possible "+mxpoynts+" points.</font></td></tr></tbody></table></center>";
document.getElementById('mynum').innerHTML = score;
}
The game's not yet on internet, so no link. With your permission may I email a zip file to you with the code, js file and other necessary files? Don't want to do that unless you say okay (either of you). Please let me know...and thanks in advance for your great help.
The js file contains a 'gw' array with the Greek words, and a 'def' array with the definitions (hints). The code randomly presents a Greek word to be discovered so I can't pinpoint which one to define. You could reduce the length of each array in the js file to, say, 3, so it has a limited number of words to work with. If you do that, also set 'playGames' to 3 (it's on line 48).
The code (and the problem I'm having) works whether or not you get the word right. Just click on any of the letters until you run out of guesses, and it will still display the current score. But it only does that when the alert is used. With the alert turned off by '//' the current score does not display.
Thanks...your quick responses are GREATLY appreciated.
Bookmarks