zoukankan      html  css  js  c++  java
  • 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;
    }

    });
    })

  • 相关阅读:
    cookie和session。
    K3cloud Web API对接---单据保存接口(有源单)
    K3 wise kis 防火墙设置
    新单序时簿插件
    mssqlserver中排序规则冲突的问题解决
    读取金蝶图片
    金蝶wise委外订单关闭简述
    存储过程加锁
    判断存储过程是否存在
    解除死锁
  • 原文地址:https://www.cnblogs.com/jameshappy/p/2988697.html
Copyright © 2011-2022 走看看