我要用php做一个网络课程,需要计算在一个子页面停留时间的代码,就是计时器代码这样的
要把值传入数据库,我不会传啊!<html><head><metahttp-equiv="Content-Type"content="text/html;charset=u...
要把值传入数据库,我不会传啊!
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript">
var hour = 0, minute = 0, second = 0;
var t = 0;
var flag1;
function studyTime()
{
hour=parseInt(t/60/60);
minute=parseInt(t/60%60);
second=parseInt(t%60);
document.getElementById('SECOND').innerHTML=second;
document.getElementById('HOUR').innerHTML=hour;
document.getElementById('MINUTE').innerHTML=minute;
t = t + 1;
flag1 = setTimeout("studyTime()", 1000);
}
//终止学习计时器
function stopTime()
{
clearTimeout(flag1);
}
</script>
</head>
<body>
小时:<div id="HOUR"></div>分钟:<div id="MINUTE"></div>秒:<div id="SECOND"></div>
<input type="submit" onclick="stopTime()" value="结束本次学习">
<script type="text/javascript">
studyTime();
</script> 展开
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript">
var hour = 0, minute = 0, second = 0;
var t = 0;
var flag1;
function studyTime()
{
hour=parseInt(t/60/60);
minute=parseInt(t/60%60);
second=parseInt(t%60);
document.getElementById('SECOND').innerHTML=second;
document.getElementById('HOUR').innerHTML=hour;
document.getElementById('MINUTE').innerHTML=minute;
t = t + 1;
flag1 = setTimeout("studyTime()", 1000);
}
//终止学习计时器
function stopTime()
{
clearTimeout(flag1);
}
</script>
</head>
<body>
小时:<div id="HOUR"></div>分钟:<div id="MINUTE"></div>秒:<div id="SECOND"></div>
<input type="submit" onclick="stopTime()" value="结束本次学习">
<script type="text/javascript">
studyTime();
</script> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询