@Sleep_ModeauthorMar 13.2006 — #I actually am coding the pairs game with javascript ( im also learning java script at that time ), and with the help of the forum, i did it in 1 day. But there should be a timer to count from 0 till the game ends...
I modified this code but it doesnt work. Why?
[code=html]var timeCount = 0;
function countDown() { var obj = document.getElementById("countdownarea"); obj.firstChild.data = timeCount;
@phpnoviceMar 13.2006 — #I modified this code but it doesnt work. Why?[/QUOTE] Hard to tell -- if you provide no more information than just the code. One thing, though, if you're trying to run multiple functions off of the [B]onload[/B] event, then you need to take special considerations for this situation. The reason is, using this format, only one function can use the [B]onload[/B] event at a time.
@phpnoviceMar 13.2006 — #And i also should write the number of pairs left each time...
I can not do this with document.write(), because when i do this, it writes to another page??? What should i do?[/QUOTE] Use a similar method as the countdown does.
@Sleep_ModeauthorMar 13.2006 — #Ok, i applied only one function to onload now. When i opened the page, it writes 0 and then it says error, so it doesnt work also?
@phpnoviceMar 13.2006 — #It doesn't need stopping. If you don't keep executing the [b]setTimeout()[/b] method, then the counter will not change anymore. So, you just need an if-test on it similar to what I had in the original code. For example... You could have a global variable that indicates whether the timer should keep running or not. Just test that global variable before executing the [b]setTimeout()[/b] method again.