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

    });
    })

  • 相关阅读:
    [转载]解决zabbix在configure时候遇到的问题(Ubuntu)
    [转载]ubuntu的版本
    [转载]Nginx如何处理一个请求
    微信小程序—文件系统
    javascript 中 x offsetX clientX screenX pageX的区别
    Bootstrap 框架、插件
    HTML自定义滚动条(仿网易邮箱滚动条)转载
    Vue 组件(上)转载
    vue $mount 和 el的区别
    $on在构造器外部添加事件$once执行一次的事件$off关闭事件
  • 原文地址:https://www.cnblogs.com/jameshappy/p/2988697.html
Copyright © 2011-2022 走看看