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;
    }

    });
    })

  • 相关阅读:
    微信小程序-上传多张图片加进度条(支持预览、删除)
    php中120个内置函数
    angular6 NgModule中定义模块module
    Aliasing input/output properties
    angular6 Can't bind to 'zzst' since it isn't a known property of
    [转]DOM 中 Property 和 Attribute 的区别
    Angular6
    [转]VirtualBox 修改UUID实现虚拟硬盘复制
    pthread_create如何传递两个参数以上的参数
    linux 线程操作问题undefined reference to 'pthread_create'的解决办法(cmake)
  • 原文地址:https://www.cnblogs.com/jameshappy/p/2988697.html
Copyright © 2011-2022 走看看