473,396 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

JavaScript Countdown reset

Hi all,

Please can someone help, I am a complete noob...

I have this code, but it is not quiet right,

Now the code below resets at 4, but I need it to reset at 8 pm
I have tried to change the code but it doesnt seem to work, it also seems to do tomorrows time rather than todays time.

Also would their be anyway so instead of saying: "and your order will be delivered tommrow" it could say "and your order will be delivered [tomorrows date i.e Wednesday 15th]"

and instead of saying: "and your order will be delivered on Tuesday" it could say "and your order will be delivered on [Tuesdays date i.e Tuesday 19th]"

I hope you understand what I am tryign to do...

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4.  
  5. <script type="text/javascript">
  6. function ord()
  7. {
  8. var c_t = 4;
  9.  
  10. var dd = new Date();
  11.  
  12. var ti_h = dd.getHours();
  13.  
  14. var ti_m = dd.getMinutes();
  15.  
  16.  
  17. if(ti_h > c_t)
  18. {
  19.  
  20. var di_t_h = ti_h - c_t;
  21.  
  22. var di_t_mi = 60 - ti_m;
  23.  
  24. var h = 24 - di_t_h;
  25.  
  26. var mi = di_t_mi;
  27.  
  28. var mess = h+"hours"+mi+"minutes";
  29.  
  30. }
  31.  
  32.  
  33.  
  34. var da = dd.getDay();
  35.  
  36. //var da = document.getElementById("da").value;
  37.  
  38. switch(da)
  39. {
  40. case 2:
  41. case 3:
  42. case 4:
  43. case 5:
  44. document.write("Place your order within the next "+mess+"and your order will be delivered tommrow");
  45. break;
  46. case 6:
  47. case 7:
  48. case 1:
  49. document.write("and your order will be delivered on Tuesday");
  50. break;
  51. }
  52. }
  53.  
  54. ord();
  55.  
  56. </script>
  57.  
  58. </head>
  59.  
  60. <body>
  61.  
  62. </body>
  63.  
  64. </html>
  65.  
  66.  
Feb 16 '11 #1
1 1525
Dheeraj Joshi
1,123 Expert 1GB
I don't know are there any java script functions allow it.
But you can add some maths and build a logic to determine the date on next Tuesday. It should net be hard.

Regards
Dheeraj Joshi
Feb 17 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Bonnett | last post by:
I have been creating a generic countdown timer (source code below), counting the seconds, minutes, hours and days till an event, but I have having trouble with it finding out how many hours are...
4
by: Christine | last post by:
I've implemented a countdown timer for a tutorial web page that should give the user 45 minutes to complete the test, only to find that the timer is slowly 'losing' time. On average, it actually...
8
by: Michael | last post by:
I have this script that works the way I want except for one thing... Once it hits zero it starts to count up and looks like this: -1:0-1:0-1:0-18 with the last number counting up. Can anyone...
31
by: Stephanie | last post by:
I have a newbie question (couldn't find the answer with google) How to show countdown from 10 to 0 seconds. Stephanie
4
by: henrik | last post by:
Hi. Can anyone tell me the python code for a simple countdown from eg. 2.00 minutes. It should be printet out to the screen. When it is finished it should write "Time is up" Hope you can...
0
by: Jorhajnes | last post by:
Hi there. Im very new to making games in flash, although I have used flash for quite some time now in web-based situations so I know my way around. Anyways, I thought it would be fun to try...
7
by: imtmub | last post by:
I have a page, Head tag Contains many Scripts and style sheet for Menu and Page. This code working fine and displaying menus and page as i wanted. Check this page for reference....
5
mageswar005
by: mageswar005 | last post by:
hi, I need a javascript countdown timer to my website, I have already the countdown timer but its have some problem. Note: 1) If i choose the tools/internet option in my browser means , at...
1
by: click2saif | last post by:
hi there iam a newbie in java i dont have any coding exp in java... And i have this task in my company to make an application in java which will be like a countdown application... The details...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.