I am trying to build a clock in clock out web app, which saves time to the database, but since i am new to php js, I just need pointers or the right direction. Reading material or something like that would be helpful too. I tried google but didnt find what i was looking for. Thanks for the help.
Since you haven't explain where you are stuck or what you have achieved so far, I cannot understand what you are looking for; Anyway i just put as an example, How to display a Clock using JavaScript. This gets time from the client computer and displays it.
<html>
<head>
<title>Clock</title>
<script type="text/javascript">
function showtime(){
if (!document.all & !document.getElementById)
return
thelement=document.getElementById? document.getElementById("DigitalClock"): document.all.DigitalClock
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
var dn="PM"
if (hours<12)
dn="AM"
if (hours>12)
hours=hours-12
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
var ctime=hours+":"+minutes+":"+seconds+" "+dn
thelement.innerHTML= ctime
setTimeout("showtime()",1000)
}
window.onload=showtime
var activeElemId;
function activateItem(elemId) {
document.getElementById(elemId).className="current";
if(null!=activeElemId) {
document.getElementById(activeElemId).className="";
}
activeElemId=elemId;
}
</script>
</head>
<body>
Digital Clock
<div class="panel-body" id="DigitalClock" style="font-size:25px;"></div>
</body>
</html>