• jquery改变 datebox改变另一个datebox的值


    //改变购买日期改变年检日期 

    $(function () {
    $("#txtPurchaseTime").datebox({
    onSelect: function () {
    //获取购买日期
    var PurchaseTime = $("#txtPurchaseTime").datebox('getValue');

    //如果购买日期为空,不用执行后续代码
    if (PurchaseTime == "" || PurchaseTime == undefined) {
    return;
    }

    //获取保险使用性质
    var InsuranceNat = $("#InsuranceNat").val();

    //租赁:年检日期=购买日期+1年;非营运:年检日期=购买日期+2年
    switch (InsuranceNat) {
    case "租赁":

    //年检日期+1年
    var tmp = new Date(Date.parse(PurchaseTime.replace(/-/g, "/")));
    var y = tmp.getFullYear() + 1;
    var m = tmp.getMonth()+1; //月份以数组存储0-11存储,需加1得到正确的月份
    var d = tmp.getDate();

    var InspectionDate = y + "-" + m + "-" + d;

    $("#txtInspectionDate").datebox("setValue", InspectionDate);

    break;

    case "非营运":

    //年检日期+2年
    var tmp = new Date(Date.parse(PurchaseTime.replace(/-/g, "/")));
    var y = tmp.getFullYear() + 2;
    var m = tmp.getMonth()+1; //月份以数组存储0-11存储,需加1得到正确的月份
    var d = tmp.getDate();

    var InspectionDate = y + "-" + m + "-" + d;

    $("#txtInspectionDate").datebox("setValue", InspectionDate);

    break;
    }
    }
    })
    })

    //改变保险使用性质改变年检日期 
    $("#InsuranceNat").change(function () {

    //获取购买日期
    var PurchaseTime = $("#txtPurchaseTime").datebox('getValue');

    //如果购买日期为空,不用执行后续代码
    if (PurchaseTime == "" || PurchaseTime == undefined) {
    return;
    }

    //获取保险使用性质
    var InsuranceNat = $("#InsuranceNat").val();

    //租赁:年检日期=购买日期+1年;非营运:年检日期=购买日期+2年
    switch (InsuranceNat) {
    case "租赁":

    //年检日期+1年
    var tmp = new Date(Date.parse(PurchaseTime.replace(/-/g, "/")));
    var y = tmp.getFullYear() + 1;
    var m = tmp.getMonth() + 1; //月份以数组存储0-11存储,需加1得到正确的月份
    var d = tmp.getDate();

    var InspectionDate = y + "-" + m + "-" + d;

    $("#txtInspectionDate").datebox("setValue", InspectionDate);

    break;

    case "非营运":

    //年检日期+2年
    var tmp = new Date(Date.parse(PurchaseTime.replace(/-/g, "/")));
    var y = tmp.getFullYear() + 2;
    var m = tmp.getMonth() + 1; //月份以数组存储0-11存储,需加1得到正确的月份
    var d = tmp.getDate();

    var InspectionDate = y + "-" + m + "-" + d;

    $("#txtInspectionDate").datebox("setValue", InspectionDate);

    break;
    }

    });
    })

  • 相关阅读:
    BZOJ2243: [SDOI2011]染色
    BZOJ3747: [POI2015]Kinoman
    BZOJ1293: [SCOI2009]生日礼物
    BZOJ3626 [LNOI2014]LCA
    BZOJ3514 Codechef MARCH14 GERALD07加强版
    BZOJ3295 [CQOI2011]动态逆序对
    BZOJ2588 [SPOJ10628]Count on a tree
    BZOJ1036 [ZJOI2008]树的统计Count
    CODEVS1490 [CTSC2008]网络管理
    BZOJ1070 [SCOI2007]修车
  • 原文地址:https://www.cnblogs.com/jameshappy/p/2988697.html
Copyright © 2020-2023  润新知