JSP计时器,该怎么解决
JSP计时器
<html>
<head>
<title>6-9</title>
<script type="text/javascript">
var c = 0;
var t;
function timedCount() {
document.getElementById('txt').value=c;
c = c+1;
t = setTimeout("timedCount()", 1000);
}
function stopCount() {
clearTimeout(t);
}
</script>
</head>
<body>
<form>
<input type="button" value="开始计时!" onclick="timedCount()">
<input type="text" id="txt">
<input type="button" value="停止计时!" onclick="stopCount()">
</form>
<p>请点击上面的“开始计时”按钮。输入框会从 0 开始一直进行计时。点击“停止计时”可停止计时。</p>
</body>
</html>
怎样使时间是自己输入进去的开始,新手求解
------解决思路----------------------
------解决思路----------------------
判断下,如果已经在计时了就跳过
<html>
<head>
<title>6-9</title>
<script type="text/javascript">
var c = 0;
var t;
function timedCount() {
document.getElementById('txt').value=c;
c = c+1;
t = setTimeout("timedCount()", 1000);
}
function stopCount() {
clearTimeout(t);
}
</script>
</head>
<body>
<form>
<input type="button" value="开始计时!" onclick="timedCount()">
<input type="text" id="txt">
<input type="button" value="停止计时!" onclick="stopCount()">
</form>
<p>请点击上面的“开始计时”按钮。输入框会从 0 开始一直进行计时。点击“停止计时”可停止计时。</p>
</body>
</html>
怎样使时间是自己输入进去的开始,新手求解
------解决思路----------------------
<html>
<head>
<title>6-9</title>
<script type="text/javascript">
var c = 0;
var t;
function timedCount() {
document.getElementById('txt').value=c;
c = c+1;
t = setTimeout("timedCount()", 1000);
}
function startCount() {
c=document.getElementById('txt').value*1;
timedCount();
}
function stopCount() {
clearTimeout(t);
}
</script>
</head>
<body>
<form>
<input type="button" value="开始计时!" onclick="startCount()">
<input type="text" id="txt" value="0">
<input type="button" value="停止计时!" onclick="stopCount()">
</form>
<p>请点击上面的“开始计时”按钮。输入框会从 0 开始一直进行计时。点击“停止计时”可停止计时。</p>
</body>
</html>
------解决思路----------------------
判断下,如果已经在计时了就跳过