<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>倒计时</title>
</head>
<body>
<input name="times" type="text" id="times" size="4" />
/ 分
<input name="StartTime" type="button" value="开始计时" onclick=
showTime();;
/>
<input name="times" type="text" id="timeShow" />
<input name="times" type="text" id="timeshow" size="8" />
<input name="StartTime" type="button" value="停止计时" onclick=
stopTime();;
/>
<form action="" method="post" name="form" id="form">
姓名:
<input name="name" type="text" />
<input name="name" type="submit" value="提交" />
</form>
</body>
</html>
<script language="javaScript">
var timesDate = null;
function startTime(pro) {
var dateTime = new Date();
var times = --pro;
document.getElementById("timeShow").value = dateTime.toLocaleString();
timesDate = window.setTimeout("startTime(" + times + ")", 1000);
if (times <= 60) {
if (times < 10) {
document.getElementById("timeshow").value = "00:00:" + "0" + times;
} else {
document.getElementById("timeshow").value = "00:00:" + times;
}
} else if (pro > 60 && pro < 3600) {
var mm = Math.floor(pro / 60);
if (mm < 10) {
if ((times - (mm * 60)) < 10) {
document.getElementById("timeshow").value = "00:0" + mm + ":"
+ "0" + (times - (mm * 60));
} else {
document.getElementById("timeshow").value = "00:0" + mm + ":"
+ (times - (mm * 60));
}
} else {
if ((times - (mm * 60)) < 10) {
document.getElementById("timeshow").value ="00:"+mm + ":" + "0"
+ (times - (mm * 60));
} else {
document.getElementById("timeshow").value ="00:"+mm + ":"
+ (times - (mm * 60));
}
}
} else if (pro >= 3600) {
var hh = Math.floor(pro / 3600);
var mm = Math.floor((pro - (hh * 3600)) / 60);
var ss = (pro - ((hh * 3600) + (mm * 60)));
if (hh < 10) {
if (mm < 10) {
if (ss < 10) {
document.getElementById("timeshow").value = "0" + hh
+ ":" + "0" + mm + ":" + "0" + ss;
} else {
document.getElementById("timeshow").value = "0" + hh
+ ":" + "0" + mm + ":" + ss;
}
} else {
document.getElementById("timeshow").value = "0" + hh + ":"
+ mm + ":" + ss;
}
} else {
if (mm < 10) {
if (ss < 10) {
document.getElementById("timeshow").value = hh + ":"
+ "0" + mm + ":" + "0" + ss;
} else {
document.getElementById("timeshow").value = hh + ":"
+ "0" + mm + ":" + ss;
}
} else {
document.getElementById("timeshow").value = hh + ":" + mm
+ ":" + ss;
}
}
}
if (pro <= 0) {
window.clearTimeout(timesDate);
var fom=document.getElementById("form");
fom.submit();
}
}
function showTime() {
var i = parseInt(document.getElementById("times").value) * 60;
startTime(i);
}
function stopTime() {
window.clearTimeout(timesDate);
}
</script>
分享到:
相关推荐
jquery+jsp 倒计时页面简单易用,放在tomcat中运行就可以
之前做过倒计时的,但是都是基于jsp客户端的时间,找了多个资料没有找到jsp直接的获取服务器时间能运行的,这次专门做了一个,供初学者学习。
倒计时载入页面 获取当前时间 时间以毫秒为单位 以倒计时方式显示时间
javascript简单的编写的时间计时器
能单独实现漂浮着的广告 也能单独实现倒计时功能 本程序可以实现漂浮着的倒计时
JSP倒计时,很不错的小例子
基于jsp技术的网页倒计时模块的实现,源代码!
这是一个间的JSP计时器 供初学者学习用
实现自定义时间 倒计时 各处都会用到的接收短信按钮 抽空封装了下 made by jxn
输入小于一小时的任意时间,点击按钮后,系统会对您输入的时间进行倒计时。
本文实例讲述了jsp倒计时简单实现方法。分享给大家供大家参考,具体如下: <%@ page language=java import=java.util.* pageEncoding=UTF-8%> <% //当前时间毫秒数 Long current_time1=System....
java web科目,用JSP格式写的倒计时
主要介绍了纯jsp实现的倒计时动态显示效果代码,涉及JSP时间操作的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下
一个jsp简单的上传下载一个jsp简单的上传下载
jsp简单上传下载,有代码,基础demo
jsp简单登录页面,适合于初学者,jsp代码
JSP实现简单购物车JSP实现简单购物车JSP实现简单购物车JSP实现简单购物车JSP实现简单购物车JSP实现简单购物车JSP实现简单购物车JSP实现简单购物车JSP实现简单购物车JSP实现简单购物车JSP实现简单购物车JSP实现简单...
JSP简单标签介绍.rar
MVC三层架构,jsp的简单留言板与mysql建立连接