/    Sign up×
Community /Pin to ProfileBookmark

advice for a timer function

hi there

I’m developing a quiz in php that spans across 20 pages but i need to have some kind of timer to limit the time taken by the user – if they don’t complete the quiz within, say, ten minutes then the final page of the quiz is called – so i thought that this would be good to do in javascript but i’m not too hot on js …

i think i can write the code for a timer that displays a countdown of remaining minutes and seconds – but i haven’t got a clue how to make it continue over each page refresh without using a separate page in a pop-up window.

what are my options here ?

thanks

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@FangAug 22.2007 — iframe, cookie or form
Copy linkTweet thisAlerts:
@steamPunkauthorAug 22.2007 — ok thanks for your reply

i can see how the cookie and iframe methods would work but how would i combine the countdown timer with the form method ?

I'm using a form for my quiz so this may be the best (and simplest) option
Copy linkTweet thisAlerts:
@FangAug 22.2007 — A hidden form field would contain the time, which is passed to the next form quiz page.

iframe is probably the simplest.
Copy linkTweet thisAlerts:
@steamPunkauthorAug 22.2007 — unfortunately an iframe isn't possible in this context

I can't just send the start time from one form page to another as i have to take into account load times for flash sound files - even if the user is on a page i can't start the timer in that page until the flash file has loaded

is it possible to dynamically update a hidden form field with the amount of time that has elapsed ?

if it is possible then i could send the cumulative number of seconds as a hidden field value - then when the flash file has finished loading it will trigger a js function in the page that will continue the countdown whilst updating the hidden form field variable

what do you think ?
Copy linkTweet thisAlerts:
@FangAug 22.2007 — Use onunload and onload to update the field and restart the timer.
×

Success!

Help @steamPunk spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...