JSP新手求教 下倒计时代码我想和数据库链接
<html><head></head><body>结束时间<inputtype="text"id="endtime"></input>相隔时间<inputtype="te...
<html>
<head>
</head>
<body>
结束时间 <input type="text" id="endtime"></input>
相隔时间 <input type="text" id="time" name="time"></input>
</body>
</html>
<script type="text/javascript" >
var databasetime = new Date(2010,7,25,18,43,56);//这里如何实现与数据库链接?
document.getElementById("uploadtime").value=dealdate(databasetime);
getdealtime();
function getdealtime(){
var now = new Date() ;
var str1 = dealdate(databasetime);
var str2 = dealdate(now);
str1 = str1.replace(/-/g,"/");
str2 = str2.replace(/-/g,"/");
var date1 = Date.parse(str1);
var date2 = Date.parse(str2);
var tmp = date1 - date2 ;
var day = parseInt(Math.floor(tmp/(24*60*60*1000)));
if(day > 0) tmp = tmp - day*24*60*60*1000 ;
var hour = parseInt(Math.floor(tmp/(60*60*1000)));
if(hour > 0) tmp = tmp - hour*60*60*1000 ;
var minute = parseInt(Math.floor(tmp/(60*1000)));
if(minute >0) tmp = tmp - minute*60*1000;
var seconds = parseInt(Math.floor(tmp/1000));
document.getElementById("time").value = day "天" hour "小时" minute "分钟" seconds "秒" ;
setTimeout("getdealtime()",1000);
}
function dealdate(date){
if(date == null){
return "" ;
}
var datestr = date.getMonth() "/" date.getDate() "/" date.getFullYear();
var hour = date.getHours().toString();
var minute = date.getMinutes().toString();
var second = date.getSeconds().toString();
if(hour.length < 2) hour = "0" hour ;
if(minute.toString().length < 2) minute = "0" minute ;
if(second.toString().length < 2) second = "0" second ;
datestr =" " hour ":" minute ":" second ;
return datestr ;
}
</script>
我想做一个类似淘宝那样的倒计时,我的数据库里有上传时间(uploadtime)一项,我想实现商家定一个上传时间(就是数据库实现),而不是后台定时间的倒计时,请问如何实现??谢谢
就是用的Struts+JSP 没有用SSH 展开
<head>
</head>
<body>
结束时间 <input type="text" id="endtime"></input>
相隔时间 <input type="text" id="time" name="time"></input>
</body>
</html>
<script type="text/javascript" >
var databasetime = new Date(2010,7,25,18,43,56);//这里如何实现与数据库链接?
document.getElementById("uploadtime").value=dealdate(databasetime);
getdealtime();
function getdealtime(){
var now = new Date() ;
var str1 = dealdate(databasetime);
var str2 = dealdate(now);
str1 = str1.replace(/-/g,"/");
str2 = str2.replace(/-/g,"/");
var date1 = Date.parse(str1);
var date2 = Date.parse(str2);
var tmp = date1 - date2 ;
var day = parseInt(Math.floor(tmp/(24*60*60*1000)));
if(day > 0) tmp = tmp - day*24*60*60*1000 ;
var hour = parseInt(Math.floor(tmp/(60*60*1000)));
if(hour > 0) tmp = tmp - hour*60*60*1000 ;
var minute = parseInt(Math.floor(tmp/(60*1000)));
if(minute >0) tmp = tmp - minute*60*1000;
var seconds = parseInt(Math.floor(tmp/1000));
document.getElementById("time").value = day "天" hour "小时" minute "分钟" seconds "秒" ;
setTimeout("getdealtime()",1000);
}
function dealdate(date){
if(date == null){
return "" ;
}
var datestr = date.getMonth() "/" date.getDate() "/" date.getFullYear();
var hour = date.getHours().toString();
var minute = date.getMinutes().toString();
var second = date.getSeconds().toString();
if(hour.length < 2) hour = "0" hour ;
if(minute.toString().length < 2) minute = "0" minute ;
if(second.toString().length < 2) second = "0" second ;
datestr =" " hour ":" minute ":" second ;
return datestr ;
}
</script>
我想做一个类似淘宝那样的倒计时,我的数据库里有上传时间(uploadtime)一项,我想实现商家定一个上传时间(就是数据库实现),而不是后台定时间的倒计时,请问如何实现??谢谢
就是用的Struts+JSP 没有用SSH 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询