日期:2014-05-16  浏览次数:20392 次

有100分赠送,时间差的计算问题
请见我另一个贴,那个有100分
这个贴回复的也给分
http://community.csdn.net/Expert/topic/5745/5745328.xml?temp=.8323633

------解决方案--------------------
妥了,L@_@K

<!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>
<title> js.parseInt.calculateTimeInterval.html </title>
<meta name= "generator " content= "editplus " />
<meta name= "author " content= "yixianggao@126.com " />
<meta name= "keywords " content= "javascript " />
<meta name= "description " content= "for javascript region of csdn " />
</head>

<body>
<pre> 已知:
1.开始时间--start (默认为9:00--可修改)
2.结束时间--stop (默认为17:30--可修改)
3.间隔时间--interrupt (单位是“分钟” ,默认为60)
求:
4.实际时间--delta (单位是“分钟”--由上述三个时间字段自动计算得出,无须手工输入 )
实际时间(小时)=结束时间-开始时间-间隔时间(分钟) </pre> <br />
<table>
<tr>
<td height= "30 "> <div align= "right "> 开始时间: </div> </td>
<td> <input id= "startTime " type= "text " size= "9 " value= "9:00 " onchange= "calculateRealInterval() " />
</tr>
<tr>
<td height= "30 "> <div align= "right "> 结束时间: </div> </td>
<td> <input id= "endTime " type= "text " size= "9 " value= "17:30 " onchange= "calculateRealInterval() " /> </td>
</tr>
<tr>
<td height= "30 "> <div align= "right "> 间隔时间: </div> </td>
<td> <input id= "interruptTime " type= "text " size= "9 " value= "60 " onchange= "calculateRealInterval() " /> 分钟 </td>
</tr>
<tr>
<td height= "30 "> <div align= "right "> 实际时间: </div> </td>
<td> <input id= "realTime " type= "text " size= "9 "/> 分钟 </td>
</tr>
</table>
<script type= "text/javascript ">
<!--
function calculateRealInterval()
{
var sTime = document.getElementById( "startTime ").value.split( ": ");
var eTime = document.getElementById( "endTime ").value.split( ": ");
var iTime = document.getElementById( "interruptTime ").value;
var rTime = document.getElementById( "realTime ");

rTime.value = (parseInt(eTime[0])*60+parseInt(eTime[1])) - (parseInt(sTime[0])*60+parseInt(sTime[1])) - parseInt(iTime);
}
calculateRealInterval();
//-->
</script>
</body>
</html>