现在有秒倒计时的功能,怎么转化成多少小时多少分,多少秒的?
text来显示倒计时的秒数,比如说还剩4000秒,我怎么做才能让他显示1小时6分40秒???
<input id="lblTime" runat="server" name="lblTime" readonly="readonly"
style="border:0px;width:50px" type="Text" visible="True" />
<script type="text/javascript">
var minutes;
function sessionTimeout()
{
var label=document.getElementById("lblTime");
minutes=parseInt(label.value);
minutes=minutes-1;
label.value=minutes.toString();
if(minutes<=0)
{
alert("您已超时");
clearInterval(sessionTimeout);
}
}
window.setInterval(sessionTimeout,1000);
</script>
------解决方案--------------------加一个控件用于显示:
<input id="Text1" type="text" />
js:
<script type="text/javascript">
var minutes;
function sessionTimeout() {
var label = document.getElementById("lblTime");
minutes = parseInt(label.value);
minutes = minutes - 1;
var h= parseInt(minutes / 3600);
var s = parseInt((minutes - h * 3600) / 60);
var m = minutes - (h * 3600 + s * 60);
document.getElementById("Text1").value = h + "小时" + s+"分钟"+m+"秒";
label.value = minutes.toString();
if (minutes <= 0) {
alert("您已超时");
clearInterval(sessionTimeout);
}
}
window.setInterval(sessionTimeout,1000);
</script>
------解决方案--------------------var minutes;
function sessionTimeout() {
var label = document.getElementById("lblTime");
minutes = parseInt(label.value);
minutes = minutes - 1;
label.value = minutes.toString();
var h = parseInt(minutes / 3600);