Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 29th, 2005, 12:02 PM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 48th Plane (28500 - 28999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 28,838 Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)  Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 1 Day 14 h 30 m 10 sec
Reputation Power: 2389
Post Javascript Countdown Timer

Below is the code needed to display count down in HTML page
using javascript.

You define container for the count down (either <span> or
<div> tag) and the initial value, and the code updates the
time automaticlly in the format HH:MM:SS

You can also control the style of the container using standard
CSS, as demonstrated in the below and attached code.

To activate the count down in one of your existing pages you
have to follow two steps:
1. include the attached CountDown.js file with:
Code:
<script type="text/javascript" src="CountDown.js"></script>

2. have such javascript in the <head> section:
Code:
<script type="text/javascript">
window.onload=WindowLoad;
function WindowLoad(event) {
	ActivateCountDown("CountDownPanel", 100);
}
</script>

where "CountDownPanel" is the ID of the container
(i.e. you should have <span> or <div> with this ID) and
100 is the time in seconds to be counted.

full source code:
javascript Code:
Original - javascript Code
  1. --CountDown.js
  2. var _countDowncontainer=0;
  3. var _currentSeconds=0;
  4.  
  5. function ActivateCountDown(strContainerID, initialValue) {
  6.     _countDowncontainer = document.getElementById(strContainerID);
  7.    
  8.     if (!_countDowncontainer) {
  9.         alert("count down error: container does not exist: "+strContainerID+
  10.             "\nmake sure html element with this ID exists");
  11.         return;
  12.     }
  13.    
  14.     SetCountdownText(initialValue);
  15.     window.setTimeout("CountDownTick()", 1000);
  16. }
  17.  
  18. function CountDownTick() {
  19.     if (_currentSeconds <= 0) {
  20.         alert("your time has expired!");
  21.         return;
  22.     }
  23.    
  24.     SetCountdownText(_currentSeconds-1);
  25.     window.setTimeout("CountDownTick()", 1000);
  26. }
  27.  
  28. function SetCountdownText(seconds) {
  29.     //store:
  30.     _currentSeconds = seconds;
  31.    
  32.     //get minutes:
  33.     var minutes=parseInt(seconds/60);
  34.    
  35.     //shrink:
  36.     seconds = (seconds%60);
  37.    
  38.     //get hours:
  39.     var hours=parseInt(minutes/60);
  40.    
  41.     //shrink:
  42.     minutes = (minutes%60);
  43.    
  44.     //build text:
  45.     var strText = AddZero(hours) + ":" + AddZero(minutes) + ":" + AddZero(seconds);
  46.    
  47.     //apply:
  48.     _countDowncontainer.innerHTML = strText;
  49. }
  50.  
  51. function AddZero(num) {
  52.     return ((num >= 0)&&(num < 10))?"0"+num:num+"";
  53. }

html4strict Code:
Original - html4strict Code
  1.  
  2. --Timer.html (sample html page with the timer)
  3. <title>Timer Test</title>
  4. <script type="text/javascript" src="CountDown.js"></script>
  5. <script type="text/javascript">
  6. window.onload=WindowLoad;
  7. function WindowLoad(event) {
  8.     ActivateCountDown("CountDownPanel", 100);
  9. }
  10. </script>
  11. <style type="text/css">
  12. #CountDownPanel {color: blue; background-color: yellow; font-size: 18px;}
  13. </style>
  14. </head>
  15. Hello!<br />
  16. Time remaining: <span id="CountDownPanel"></span>
  17. </body>
  18. </html>


edit:
I've added AdvancedCountDown.zip file with advanced options:
  1. supporting more than one container (no limit)
  2. supporting stopping and continuing each count down
  3. real time flow: alerts no longer pause the count down.


edit:
Added extra functionality in the advanced options:
  1. supporting callbacks: once the timer has ended, callback
    function is called. this means you no longer have to change
    anything in the JavaScript file itself.
  2. supporting date formats. you can add the date_format
    attribute to the container with any format you like.
    supported keys:
    • %d - Days
    • %h - Hours
    • %m - Minutes
    • %s - Seconds
    default format is %h:%m:%s
  3. supporting changing the time at runtime. see the .html
    file for example of using it.

edit:
Added extra functionality in the advanced options:
  1. supporting "RAW" time_format flag, when raised the timer
    will show the raw value instead of the formatted time.
  2. supporting "second_value" attribute: when set, given value
    will be subtracted from the value in every second. (instead of 1)
  3. supporting "finish_value" attribute: when set, current value
    will be compared against it instead of against zero.
see the second Timer in the .html file for example of all above.

Happy Programming!
Comments on this post
RadioactiveFrog agrees: cool
Attached Files
File Type: zip Timer.zip (978 Bytes, 25638 views)
File Type: zip AdvancedCountDown.zip (2.5 KB, 2123 views)

Last edited by Shadow Wizard : November 24th, 2008 at 05:38 AM. Reason: updated advanced countdown files

Reply With Quote
  #2  
Old July 6th, 2006, 06:00 PM
brightspot brightspot is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 2 brightspot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 34 sec
Reputation Power: 0
my onmouseover doesn't work now

Hi Shadow Wizard,

I would like to use your code. It's cool. I have a question, though. I have a complicated multipage classic ASP, VB Script, SQL Server and Javascript web site. When I included your code - which works well! Thank you. - my mouse over stopped working. Here is the code I'm using for the mouseover:

Code:
 %>
              <INPUT TYPE=BUTTON STYLE='font-size:10px;width:140px' 
                onClick="add_commodity(<% =RS("CommodityID") %>,'<% =Trim(RS("Commodity")) %>')" 
                VALUE='<% =Trim(RS("Commodity")) %>'
                onMouseOver="writetxt('<% =Replace(msgtxt,"'","") %>')" 
                onMouseOut="writetxt(0)">&nbsp;
              <%


I inherited this code and its a real mix of stuff with VB Script writing html. Do you know if there is something natively incompatible with your code (maybe the onload?) and onmouseover? I'm really at a loss as to where to start looking.

Thanks,
Chris

Reply With Quote
  #3  
Old July 10th, 2006, 05:33 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 48th Plane (28500 - 28999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 28,838 Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)  Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 1 Day 14 h 30 m 10 sec
Reputation Power: 2389
yes those lines are overwriting the window load:
Code:
window.onload=WindowLoad;
function WindowLoad(event) {
    ActivateCountDown("CountDownPanel", 100);
}

if you already have onload code, you have to add this to my function.
attach the whole page source code in zip file and I'll have a look - hopefully
it will be something simple and quick.

Reply With Quote
  #4  
Old July 10th, 2006, 06:03 PM
brightspot brightspot is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 2 brightspot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 34 sec
Reputation Power: 0
zip file of our source

Hi ShadowWizard,

I am unable to attach all the source files. This web site is huge with multiple includes and intertwined code. In fact, you won't find the </BODY> in this file. It gets included down the stream someplace.

I started over inserting your code to make sure I followed your directions precisely and ended up with the attached code. The words: "Time remaining" is displayed on the page, but the countdown numbers do not appear. The onmouseover DOES work with this version of the code.

Thanks for your help,
Chris
Attached Files
File Type: zip shadowWizard.zip (2.4 KB, 771 views)

Reply With Quote
  #5  
Old July 11th, 2006, 04:13 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 48th Plane (28500 - 28999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 28,838 Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)  Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 1 Day 14 h 30 m 10 sec
Reputation Power: 2389
ok, in header.asp change those lines:
Code:
<script type="text/javascript">window.onload=WindowLoad;function WindowLoad(event)
 {    ActivateCountDown("CountDownPanel", 100);}</script>

to be this:
Code:
<script type="text/javascript">
window.onload=WindowLoad;
function WindowLoad(event) {
   loadCookies();
   ActivateCountDown("CountDownPanel", 100);
}
</script>

and this:
Code:
<body onload="loadCookies();" MARGINHEIGHT="0" MARGINWIDTH="0" LEFTMARGIN="0" TOPMARGIN="0" BOTTOMMARGIN="0" RIGHTMARGIN="0">

to this: (remove the function from the body tag)
Code:
<body MARGINHEIGHT="0" MARGINWIDTH="0" LEFTMARGIN="0" TOPMARGIN="0" BOTTOMMARGIN="0" RIGHTMARGIN="0">

Reply With Quote
  #6  
Old October 27th, 2006, 01:31 PM
ashishtekwani89 ashishtekwani89 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 1 ashishtekwani89 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 59 sec
Reputation Power: 0
Timer

Hi!!

I found your timer useful for my project. Thanks a lot. i have 1 question. After the message your time has expired i want it to go to a different page. please send me the codings for this to
E-MAIL

Thanks a lot



Quote:
Originally Posted by Shadow Wizard
Below is the code needed to display count down in HTML page
using javascript.

You define container for the count down (either <span> or
<div> tag) and the initial value, and the code updates the
time automaticlly in the format HH:MM:SS

You can also control the style of the container using standard
CSS, as demonstrated in the below and attached code.

To activate the count down in one of your existing pages you
have to follow two steps:
1. include the attached CountDown.js file with:
Code:
<script type="text/javascript" src="CountDown.js"></script>

2. have such javascript in the <head> section:
Code:
<script type="text/javascript">
window.onload=WindowLoad;
function WindowLoad(event) {
	ActivateCountDown("CountDownPanel", 100);
}
</script>

where "CountDownPanel" is the ID of the container
(i.e. you should have <span> or <div> with this ID) and
100 is the time in seconds to be counted.

full source code:
javascript Code:
Original - javascript Code
  1. --CountDown.js
  2. var _countDowncontainer=0;
  3. var _currentSeconds=0;
  4.  
  5. function ActivateCountDown(strContainerID, initialValue) {
  6.     _countDowncontainer = document.getElementById(strContainerID);
  7.    
  8.     if (!_countDowncontainer) {
  9.         alert("count down error: container does not exist: "+strContainerID+
  10.             "\nmake sure html element with this ID exists");
  11.         return;
  12.     }
  13.    
  14.     SetCountdownText(initialValue);
  15.     window.setTimeout("CountDownTick()", 1000);
  16. }
  17.  
  18. function CountDownTick() {
  19.     if (_currentSeconds <= 0) {
  20.         alert("your time has expired!");
  21.         return;
  22.     }
  23.    
  24.     SetCountdownText(_currentSeconds-1);
  25.     window.setTimeout("CountDownTick()", 1000);
  26. }
  27.  
  28. function SetCountdownText(seconds) {
  29.     //store:
  30.     _currentSeconds = seconds;
  31.    
  32.     //get minutes:
  33.     var minutes=parseInt(seconds/60);
  34.    
  35.     //shrink:
  36.     seconds = (seconds%60);
  37.    
  38.     //get hours:
  39.     var hours=parseInt(minutes/60);
  40.    
  41.     //shrink:
  42.     minutes = (minutes%60);
  43.    
  44.     //build text:
  45.     var strText = AddZero(hours) + ":" + AddZero(minutes) + ":" + AddZero(seconds);
  46.    
  47.     //apply:
  48.     _countDowncontainer.innerHTML = strText;
  49. }
  50.  
  51. function AddZero(num) {
  52.     return ((num >= 0)&&(num < 10))?"0"+num:num+"";
  53. }

html4strict Code:
Original - html4strict Code
  1.  
  2. --Timer.html (sample html page with the timer)
  3. <title>Timer Test</title>
  4. <script type="text/javascript" src="CountDown.js"></script>
  5. <script type="text/javascript">
  6. window.onload=WindowLoad;
  7. function WindowLoad(event) {
  8.     ActivateCountDown("CountDownPanel", 100);
  9. }
  10. </script>
  11. <style type="text/css">
  12. #CountDownPanel {color: blue; background-color: yellow; font-size: 18px;}
  13. </style>
  14. </head>
  15. Hello!<br />
  16. Time remaining: <span id="CountDownPanel"></span>
  17. </body>
  18. </html>


Happy Programming!

Reply With Quote
  #7  
Old October 29th, 2006, 03:20 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 48th Plane (28500 - 28999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 28,838 Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)  Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 1 Day 14 h 30 m 10 sec
Reputation Power: 2389
Quote:
Originally Posted by ashishtekwani89
Hi!!

I found your timer useful for my project. Thanks a lot. i have 1 question. After the message your time has expired i want it to go to a different page. please send me the codings for this to
E-MAIL

Thanks a lot
hello and welcome to aspfree,

to do this add this line to the code:
Code:
if (_currentSeconds <= 0) {
        alert("your time has expired!");
        document.location = "otherpage.html";
        return;
}

add the line in bold to the code in CountDownTick function.

Reply With Quote
  #8  
Old April 11th, 2007, 02:36 PM
enggars enggars is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 1 enggars User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 51 sec
Reputation Power: 0
Arrow Your script is helpful, but i need some help using them

Hello...
I have a quiz application based on ASP.
I use paging, which is showing only one question per page.
I want to set a time limitation on the application.
The problem is i cant use the window.onload since the time will started again if we move to another question.

What i want to do is i want the time limitation only loaded once at the beginning. though we move to the prev or next page, the time will keep on counting without being started again.
Can you help me with this?

Many thanks for the helps....

Reply With Quote
  #9  
Old April 12th, 2007, 06:06 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 48th Plane (28500 - 28999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 28,838 Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)  Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 1 Day 14 h 30 m 10 sec
Reputation Power: 2389
for this, ASP or some other server side language is needed.
assuming you work with ASP, assign session variable with the
current date and time when the user begin the quiz:
Code:
Session("TimeQuizBegin") = Now

now, change this line:
Code:
ActivateCountDown("CountDownPanel", 100);

to this:
Code:
ActivateCountDown("CountDownPanel", <%=(600-Abs(DateDiff("s", Now, Session("TimeQuizBegin"))))%>);

replace 600 with the amount of seconds the user has to complete the
quiz, in the above code it's 10 minutes.
good luck and let me know if you bump into any further problem.

Reply With Quote
  #10  
Old April 19th, 2007, 03:34 AM
shubha_vasisht shubha_vasisht is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Mysore
Posts: 1 shubha_vasisht User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 13 sec
Reputation Power: 0
timer gets refreshed on click of back and refresh

hi all...

in my application count down timer is working fine..
but the problem is onclick of back button / refresh button timer will be refreshed that is it starts its count from the starting.

actually this shouldnt happen in my application. when the user clicks back button or refresh button, i want to call button click event by which user will be to taken to the next question in the online quiz.

but am not getting how to achieve this. so if anybody could help me in this..

tks in advance

regards,
Shubha

Reply With Quote
  #11  
Old April 19th, 2007, 03:50 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 48th Plane (28500 - 28999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 28,838 Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)  Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 1 Day 14 h 30 m 10 sec
Reputation Power: 2389
read my previous reply - what you need is to store
the time on the server, client side scripting lack
what you need.

Reply With Quote
  #12  
Old July 24th, 2007, 03:38 AM
danr1660 danr1660 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Posts: 1 danr1660 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 58 sec
Reputation Power: 0
Awesome script

Hi,
I just found this script and have added it to my website and it's working great. I have a couple of questions.

1. I have added the script to my master page so it shows on every page which is what I want. The question is how to make it so the countdown does not start over everytime I go to a new page?

2. Is there anyway to loop this so that when the countdown expires and the window pops up and the user clicks ok it will reset and start the countdown again?

Thanks in advance for your help

Dan

Reply With Quote
  #13  
Old July 24th, 2007, 04:08 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 48th Plane (28500 - 28999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 28,838 Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)  Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 1 Day 14 h 30 m 10 sec
Reputation Power: 2389
hi Dan,
answer to your first question: read my previous reply in this thread
and the one before. this question has been asked already.

answer to your second question:
change this block of code:
Code:
if (_currentSeconds <= 0) {
	alert("your time has expired!");
	return;
}

to this:
Code:
if (_currentSeconds <= 0) {
	alert("your time has expired!");
	_currentSeconds = 120; //two minutes
}

of course, change the number to whatever amount
of seconds you wish.

Reply With Quote
  #14  
Old September 8th, 2007, 09:59 AM
ScriptNewbie ScriptNewbie is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 4 ScriptNewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 m 12 sec
Reputation Power: 0
submit the form after timeout

Hi....

Thanks for ur code.. I was able to run the timer code successfully....

I am a newbie to java script... And i want to know how should i submit(post method) my html form after timeout.

Thanks for ur help...

Reply With Quote
  #15  
Old September 9th, 2007, 03:39 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 48th Plane (28500 - 28999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 28,838 Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)  Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 1 Day 14 h 30 m 10 sec
Reputation Power: 2389
change this line:
Code:
alert("your time has expired!");

to this:
Code:
document.forms[0].submit();

I assume you have only one form in your page.
you can also have both the alert and the submit.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Javascript Countdown Timer


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek