morocco-iceberg Posted May 20, 2010 Share Posted May 20, 2010 My brain hurts.. I've been trying to find a tutorial or something to teach me how to create a Javascript timer (I don't know much Javascript at all, I tend to despise it for most things but I can't avoid it for this project), but I can't find what I'm looking for. Basically, I'm creating an online exam, which requires a visible countdown timer that begins at 45min with an alert at 15min and another alert at 5min. Once the timer is finished I need the page to automatically send the form and move onto the next section of the exam, or if the user moves onto the next part of the exam before the timer finishes I need to take note of how much time they spent on that section. Could someone please point me to either a code generator, tutorial or help me get it started? Quote Link to comment Share on other sites More sharing options...
Ang3l0fDeath Posted May 23, 2010 Share Posted May 23, 2010 You'll have to forgive me not giving you an exact working example. Im giving you the framework you need. I could give you a better code and more helpful code if i have some additional information. where is the timer on your page? and big is the timer section like 20x20? 40x40? 60x60? 80x80? Also i suggest you put a clock with the timer, its very helpful in allowing a person to know the time and when they should be done. Also what type of exam is this and whats it for? Javascript is helpful with user-friendly functions, but there could be a security problem if you relay 100% on javascript to handle the whole timing of the exam. Reason why i say javascript could have a security issue is cause anything and everything javascript could be hacked since its on the client user end. // create a function to start your timer. // page onload event works best // button onclick works well too. var mins_limit = 45;//personally i use seconds cause its more accurate var limit_seconds = mins_limit*60;//see i made a seconds thingy. var start_time = 0;//This varible is the start of the 45 minutes. function start_timer(){ // i stopped my work here cause idk what you got to work with. Setting a timer is easy, but you still got to output the varibles into elements/fields which with a simple timer you only need 1 output area, but if you want something a bit more like i said above it could take 4-6 id fields and a bit more functions / math / work. } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.