Click to See Complete Forum and Search --> : A question related to functions


Acrappa
05-06-2003, 02:42 AM
First of all, here is my project:

http://members.cox.net/acrappa/javascript/project9.html

Everything related to the quiz itself is working properly. What I am working on now is the scrollbar status which displays how long the user has been working on the test. This is done with setInterval and a function. The counter works how I want it to, too. The issue that I am trying to resolve is, at the end of the quiz, the results are prompted to the user, and in there I want to display how long it took the user to complete the quiz. The problem is that the time information is stored in a variable within one function and thus can't be called in another. At least, there is no way that I know of to do this. What would be the ideal way to display how long it took the user complete the quiz in the dialogue box?

Also, is there a way to have the timer stop counting when the user presses the Submit Quiz button?

Fang
05-06-2003, 04:24 AM
Your time variables are global, so you can access them from any function.
Use clearInterval() to stop the timer.

Charles
05-06-2003, 04:35 AM
Be aware that there are accessibility problems with timed responses. See http://www.access-board.gov/sec508/guide/1194.22.htm#(p).

Acrappa
05-06-2003, 04:43 PM
Fang,
I tried to use the variables before, but I must have done something wrong because they weren't working. Reading your post, I gave it another try, and everything is working how I want. Thanks a bunch for the "duh!". :)

Charles,
Thanks for the heads-up. I am doing this for a school project though, and the timer is required.