日历My97DatePicker绑定

1 绑定日期
导入My97DatePicker/WdatePicker.js
body中加入:
<input type="text" id="date" name="date" class="Wdate" onfocus="WdatePicker()" readonly="readonly" />

2 绑定类似开始日期-结束日期
导入My97DatePicker/WdatePicker.js
<script type="text/javascript">
function controlDate(){
    var date1 = document.getElementById("startTime").value;
    if (date1!="") {
	var year = date1.substr(0,4);
	var month_1 = date1.substr(5,1);
	var month_2 = date1.substr(6,1);
	var last ;
	if (month_1=="0") {
		last = year+'-'+(parseInt(month_2)+1)+'-01';
	}else {
		last = year+'-'+(parseInt(month_1+month_2)+1)+'-01';
	}
	document.getElementById("lastDate").value=last;
	WdatePicker({minDate:'#F{$dp.$D(\'startTime\',{d:2});}',maxDate:'#F{$dp.$D(\'lastDate\',{d:-1});}'});
    }else {
	WdatePicker();
    }
 }
</script>

body中加入:
<input type="text" id="startTime" name="startTime" class="Wdate" onfocus="WdatePicker()" readonly="readonly" />&nbsp;&nbsp;-
<input type="hidden" id="lastDate" />
<input type="text" id="endTime" name="endTime" class="Wdate" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'startTime\',{d:1});}'});" readonly="readonly" />

你可能感兴趣的:(my97datepicker)