js 设置默认时间

三世轮回 提交于 2020-03-26 08:34:06

 

 

 

                            <td class="title95">计划生产日期</td>
                            <td>
                                <input id="BeginSch" name="BenginProdceDate" class="easyui-datebox filewidth_n" type="datetime" data-options="required:false,validType:['DateDay'],onSelect:function(){fullnum('BeginSch','EndSch')}">
                            </td>
                            <td align="center">至</td>
                            <td>
                                <input id="EndSch" name="EndProdceDate" class="easyui-datebox filewidth_n" style="width:150px" type="datetime" data-options="required:false,validType:['DateDay'],onSelect:function(){fullnum('BeginSch','EndSch')}">
                            </td> 


 SetSearchDay('BeginSch', 'EndSch', 1, 7)

//初始化设置查询时间
//beginID:开始的Id名称 
//EndID:结束的Id名称 
//Type:1:向前,2向后
//SpanDays: 间隔天数
function SetSearchDay(BeginID, EndID, Type, SpanDays) { 
    var fdate ;
    var tdate ;
    if (Type == 1) {
        fdate = (new Date().getFullYear()) + "-" + (new Date().getMonth() + 1) + "-" + (new Date().getDate() );
        tdate = (new Date().getFullYear()) + "-" + (new Date().getMonth() + 1) + "-" + (new Date().getDate() + SpanDays);
    } else if (Type == 2) {
        fdate = (new Date().getFullYear()) + "-" + (new Date().getMonth() + 1) + "-" + (new Date().getDate() - SpanDays);
        tdate = (new Date().getFullYear()) + "-" + (new Date().getMonth() + 1) + "-" + (new Date().getDate());
    }

    $("#" + BeginID).datebox('setValue', fdate);
    $("#" + EndID).datebox('setValue', tdate);
}

  

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!