Count Down/up Script /alarm Clock

Apr 9, 2004

This script counts up, counts down and incorperates an alarm clock!

<html>
<head>
<script type="text/javascript">
var hv;
var mv;
var sv;
var timer;
var timer2;
function set(){
hv=document.getElementById("h").value*1;
mv=document.getElementById("m").value*1;
sv=document.getElementById("s").value*1;
}
function countup(){
if(sv!=59){
sv++
}
else if(mv!=59){
mv++
sv=0;
}
else if(hv!=59){
hv++
mv=0;
sv=0;
}
else{
alert("Finished counting up!")
clearTimeout(timer);
}
if(sv<10){
sv2="0"+sv;
}
else{sv2=sv}
if(mv<10){
mv2="0"+mv;
}
else{mv2=mv}
if(hv<10){
hv2="0"+hv;
}
else{hv2=hv}
document.getElementById("h").value=hv2;
document.getElementById("m").value=mv2;
document.getElementById("s").value=sv2;
}
function countdown(){
if(sv!=00){
sv--
}
else if(mv!=00){
mv--
sv=59;
}
else if(hv!=00){
hv--
mv=59;
sv=59;
}
else{
alert("Finished counting down!")
clearTimeout(timer2);
}
if(sv<10){
sv2="0"+sv;
}
else{sv2=sv}
if(mv<10){
mv2="0"+mv;
}
else{mv2=mv}
if(hv<10){
hv2="0"+hv;
}
else{hv2=hv}
document.getElementById("h").value=hv2;
document.getElementById("m").value=mv2;
document.getElementById("s").value=sv2;
}
function thetime(){
var d=new Date();
var hours=d.getHours();
var mins=d.getMinutes();
var secs=d.getSeconds();
if(hours<10){
hours="0"+hours;
}
if(mins<10){
mins="0"+mins;
}
if(secs<10){
secs="0"+secs;
}
document.getElementById("times").value=hours+":"+mins+":"+secs;
if(timer==true && hours==hv && mins==mv && secs==sv){
alert("Alarm ringing!")
}
}
function alarmonoff(){
if(document.getElementById("alarmbut").value=="Turn alarm on/set"){
timer=true;
document.getElementById("alarmbut").value="Turn alarm off/set";
}
else{
timer=false;
document.getElementById("alarmbut").value="Turn alarm on/set";
}
}
</script>
</head>

<body onload="setInterval('thetime()',500)">

<table border="0">
<tr>
<td colspan="2"><input value="00" size="2" id="h">:<input value="00" size="2" id="m">:<input value="00" size="2" id="s"></td>
</tr>
<tr>
<td><input type="text" size="8" id="times"></td>
<td><input type="button" value="Stop" onclick="set(); clearTimeout(timer); clearTimeout(timer2)"></td>
</tr>
<tr>
<td><input type="button" value="Count up" onclick="set(); timer=setInterval('countup()',1000)"></td>
<td><input type="button" value="Count down" onclick="set(); timer2=setInterval('countdown()',1000)"></td>
</tr>
<tr>
<td colspan="2"><input type="button" value="Turn alarm on/set" onclick="set(); alarmonoff()" id="alarmbut"></td>
</tr>
</table>

</body>

</html>


To count up, enter time to count up from. stops and alerts at 59:59:59. Press stop to stop.

To count down, enter time to count down from. Stops and alerts at 00:00:00. Press stop to stop.

To set alarm, enter time. Click Turn alarm on/set once or Turn alarm off/set twice. Click Turn alarm off/set to cancel alarm.

Any comments/suggestions welcome.

View 16 Replies


ADVERTISEMENT

Modification To The Alarm Clock Script

Jun 4, 2009

How can I change the behavior of the alarm clock script from Javascript Kit located here [url] to make it so that it displays a simple alert message instead of following a link?

View 3 Replies View Related

Alarm Clock With Target Will Open In New Window

Apr 10, 2011

I have here codes for alarm clock but the thing is that I want the specified target URL to open in new window. If and only if I have a background with this programming maybe I could do it. I found this code from javascriptkit (credit to them)

<html>
<head>
<style type="text/css">
#jsalarmclock{
font-family: Tahoma;
font-weight: bold;
font-size: 12px;
} .....

View 3 Replies View Related

Count Down Clock That Will Count Down 18 Minutes And Reset Itself At The End?

Sep 15, 2009

I need a count down clock that will count down 18 minutes and reset itself at the end. also i need a counter that increases by +1 every 18 minutes starting at 0.

View 1 Replies View Related

Making A Count Down Clock Repeat Daily?

Jul 8, 2010

What im trying to do is have a count down timer count down to the same time every day. For example, if i set it to count down to July 9th 2010 8:00pm. At 8pm i want it to pause or wait for 30 min. During that time i want it to display some text. After that 30min is up i want to reset it to count down to the same time the next day. (July 9th 2010 8:00pm) ect. I figgured maybe adding 23 1/2 hours to it but i dont even no how to reset this thing, let alone change the time it counts down to.Im not asking any one to do this for me (though i wouldnt hate it) but i really need some direction. All i really think i know is that some functions nned to be placed n the "Else - (if variable = 0) then ........." Here is the javascript im using (it works but does not reset) it also takes some information from php:

Code:

// Here�s where the Javascript starts
countdown = <?=$diff?>;
// Converting date difference from seconds to actual time
function convert_to_time(secs)

[code]...

View 3 Replies View Related

Creating A LED To Trigger An Alarm?

Jul 6, 2011

I'm looking to create an LED like this:

in Javascript. I didn't know if this was possible at all. I have an program written in C that starts an agent and updates an XML file with data. I wanted to turn the LED on when the alarm was running, and have it off when the alarm was not running. I tried searching "LED in Javascript" but nothing came up. The image above is a LED created in a program called Labview, which I use frequently. I just trying to figure out how exactly to create one in Javascript.

View 1 Replies View Related

Count-down+target-date+then-count-up?

Jun 20, 2011

I have basic JS knowledge. I am trying to organize a JS timer which counts down to a specific date. After the target date is meet the timer starts to count up. Can someone point me to a JS sample which executes this count-down+target-date+then-count-up theme?

View 2 Replies View Related

Clock - Won't Update Every Second

Oct 18, 2009

I'm somewhat new to JavaScript and for my website, I decided to make a clock for the website in this format:
Saturday, October 17, 2009 5:56:14 p.m. The only issue is that it won't update every second. Below is the coding:

External JavaScript:
function dateClock()
{
// Coding
}
setTimeout("dateClock()", 1000);
[Code]...

View 4 Replies View Related

Get 1 Tenth Of A Second For My Clock?

Apr 4, 2010

How can I get 1 tenth of a second for my clock? (bad typo for clock. I had to edit it. I'm saying that for the admin because I know you're not suppose to edit excessively)

View 5 Replies View Related

Clock That Follows Your Mouse

Oct 20, 2003

Add this to your page and you will have a Clock and Date that follows your mouse wherever it goes ......

View 2 Replies View Related

Clock Code

Oct 31, 2005

I hoping one of you guys can help i'm developing an ecommerce site that has items available for next day delivery. The cut off point for receiving an item next day is 2.00pm.

If possible i need a script that if the time is before 2.00pm i just need some text displaying tomorrows date and when the time goes after 2.00pm the date shown will the day after tomorrows date. If poss i need it in this format "28 October 2005"

View 2 Replies View Related

Countdown Clock

Oct 10, 2005

I am looking for a simple countdown clock that displays a countdown in days, hours, minutes and seconds. I do have one on my sites's CPanel, but I don't really like the look of it. I'm not really looking for anything specific, if it looks good then I'll use it.

I wondered if anyone knows where I can get a countdown clock from?

View 2 Replies View Related

Make A Second Clock?

Feb 26, 2010

How can i make a second clock taking time from some point, like for example from 23.4.2001 09:46:23?

View 3 Replies View Related

Display Clock In An Input Box?

Jun 29, 2009

This script displays a time and date using a document write tag, I want to display it in a input form box, I tried using this tag but just don't know how to write it:

document.form.date.value=""
<form name='form'>
<input type='text' name='date' size='30'>

[code]....

View 2 Replies View Related

World Clock - Add Day To The Output

Jun 22, 2010

How I would output the day as well in this

[url] world clock example?

View 6 Replies View Related

Stop And Then Start JS Clock

Jan 3, 2011

I am trying to stop and then start my clock, but something goes wrong

<script type="text/javascript">
function start_clock(){
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
[Code]...

View 6 Replies View Related

Adding Clock To Website?

Jan 7, 2011

I want to add a list of several clocks to my website, with different time zones. I found this code and thought that if I repeated it a few times - see below, and simply put a '-4' or whatever after the hours to make the different time, that would be fine. However, it only works for the first one.

<form name="Tick">
<input type="text" size="11" name="Clock">
</form>
<script>

[Code]....

View 6 Replies View Related

Images Used In A Digital Clock?

Jan 20, 2011

I have to make a digital clock (which i did figure out) but the number needs to be images with the numbers on them. (ex.: (an image of the number 1+an image of the number 2+image of number 0+images of number8) would be 11:08))

Here's what I have so far. Do I need to use <img src=""> in a function then call the function for my images?

View 1 Replies View Related

Add Leading Zero To Hours In Clock?

Jun 10, 2011

I am trying to edit one small thing in the javascript below but cannot get it to work correctly

What I am wanting to do is have the time with a 0 before the hour all the time except for 10, 11 or 12 o clock (e.g 09:00) I tried adding the following code it works but only for AM time and not PM time: -

// Pad the Hours with leading zeros, if required
currentHours = ( currentHours < 10 ? "0" : "" ) + currentHours;
Heres the code:
function init ( )
{
timeDisplay = document.createTextNode ( "" );

[Code]....

View 9 Replies View Related

Countdown Clock Using Array?

Feb 13, 2011

I have the javascript to create a countdown clock but i need to use Arrays to show multiple countdown clocks for different time.

[Code]...

View 2 Replies View Related

Countdown Clock Not Working In IE Or IOS?

Mar 31, 2011

I've got some code off of the web I'm using on my website, it is a javascript clock, it works fine in firefox and thats it, I would like to get it working in at least IE.

[Code]...

View 3 Replies View Related

Analog Clock Which Works In IE 6?

Jul 29, 2010

Any ideas where I can get a free one from?

Like on the bbc website.

View 4 Replies View Related

Countdown Clock - Make It Run Every Second

Mar 6, 2010

I'm trying to make a countdown clock and it works, except only when you load it. After it's loaded it just displays the time from when you got there. Is there a way to make it run every second? I tried setTimeout("countDown()",1000) But I can't seem to get it to work. I have found others that work but they only go to one date, and I need one that restarts every Sunday.

View 4 Replies View Related

How To Code A Countdown Clock

Jul 22, 2010

I am new at web development and am just getting aquainted with JaveScript. I have seen a countdown clock on another web site and wouldl like to code the same on my web site. I have been through the [URL] javascript tutorial and could not find any reference to that specific code. I'm sure it is somewhere in the date functions. how to code a countdown clock?

View 2 Replies View Related

30 Minute Countdown Clock?

Sep 14, 2010

I have created a 30:00 Countdown Clock but when it gets to 9 seconds in the seconds field it shows a 9 instead of 09

Example

This is what I get: 29:9

This is what I need: 29:09

Not sure how to do it, I am new to working with JavaScript

<form name="counter"><input type="text" size="8"
name="d2"></form>
<script>[code]......

View 7 Replies View Related

Implementing A Countdown Clock From Within A Php Page?

Jul 27, 2009

Im having trouble implementing a countdown clock from within a php page. I am using the countdown clock from dynamic drive. It works well if I have the javascript in the php page, but when I move it to an external js file clock.js it gives an 'invalid date'. Does it have something to do with the php tags inside the function ? below is the code.

callclock.php
<script src="clock.js" language="javascript" type="text/javascript">
</script>

[code]....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved