标签:Fix min val func bre else 字符 type 开始
$(function () {
if ($() {
$("input[name=‘DATA_16‘]").attr("onchange", "jsTime()");
$("input[name=‘DATA_17‘]").attr("onchange", "jsTime()");
$("select[name=‘DATA_18‘]").attr("onchange", "jsTime()");
$("select[name=‘DATA_19‘]").attr("onchange", "jsTime()");
//$("input[name=‘DATA_7‘]").attr("readonly", "readonly");
}
})
function jsTime() {
var startDate = $("input[name=‘DATA_16‘]").val();//开始日期
var EndDate = $("input[name=‘DATA_17‘]").val();//结束日期
startDate = startDate.replace("T", " ");
EndDate = EndDate.replace("T", " ");
if (startDate > EndDate) {
alert("开始日期不应大于结束日期!");
}
else {
GetDateDiff(startDate, EndDate ,"day");
}
}
function GetDateDiff(startTime, endTime, diffType) {
//将xxxx-xx-xx的时间格式,转换为 xxxx/xx/xx的格式
startTime = startTime.replace(/\-/g, "/");
endTime = endTime.replace(/\-/g, "/");
//将计算间隔类性字符转换为小写
diffType = diffType.toLowerCase();
var sTime = new Date(startTime); //开始时间
var eTime = new Date(endTime); //结束时间
//作为除数的数字
var timeType = 1;
switch (diffType) {
case "second":
timeType = 1000;
break;
case "minute":
timeType = 1000 * 60;
break;
case "hour":
timeType = 1000 * 3600;
break;
case "day":
timeType = 1000 * 3600 * 24;
break;
default:
break;
}
var Request = (eTime.getTime() - sTime.getTime()) / parseInt(timeType) //计算时间
Request = Request.toFixed(1);
var d = 0.5;
if($("select[name=‘DATA_18‘]").val() != $("select[name=‘DATA_19‘]").val())
d = 1;
Request = parseFloat(Request);
d = parseFloat(d);
$("input[name=‘DATA_7‘]").val(Request + d);
}
标签:Fix min val func bre else 字符 type 开始
原文地址:https://www.cnblogs.com/wulonglong/p/12207207.html