Time On Button With Message

[Total: 0    Average: 0/5]

This shows a clock on a form button.

Head Code:

<script Language="JavaScript">
<!-- Hide me from other browsers
var timerID = null;
var timerRunning = false;
function stopclock (){
        if(timerRunning)
                clearTimeout(timerID);
        timerRunning = false;
}
function startclock () {
        // Make sure the clock is stopped
        stopclock();
        showtime();
}
function showtime () {
        var now = new Date();
        var hours = now.getHours();
        var h=hours;
        var minutes = now.getMinutes();
        var seconds = now.getSeconds()
        var timeValue = "" + ((hours >12) ? hours -12 :hours)
        timeValue += ((minutes < 10) ? ":0" : ":") + minutes
        timeValue += ((seconds < 10) ? ":0" : ":") + seconds
        timeValue += (hours >= 12) ? " P.M." : " A.M."
        document.clock.face.value = timeValue;
        window.status = timeValue;
        timerID = setTimeout("showtime()",1000);
        timerRunning = true;
        if (h >= 18)
        document.clock.face1.value = "Good Evening"


}



// Netscapes Clock - Stop  -->
</script>

Body Code:

<form name="clock" onSubmit="0">
<div align=center>
<input type="button" name="face"  value="xxxxxxxxxx">
<input type="button" name="face1" value="xxxxxxxxxx">
</div>
<a href="javascript:startclock()">start clock by clicking</a>

</form>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *