代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>根据条件决定My97DatePicker日期控件弹出的日期格式</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
</head>
<body> <div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-default m-top">
<div class="panel-heading">上传</div>
<div class="panel-body">
<form method="" action="" class="form-horizontal">
<div class="form-group form-group-sm">
<label for="bfjis" class="col-sm-4 control-label">是否按日:</label>
<div class="col-sm-4">
<select name="bfjis" id="bfjis" class="form-control">
<option value="0">是</option>
<option value="1">否</option>
</select>
</div>
</div>
<div class="form-group form-group-sm">
<label for="tranDate" class="col-sm-4 control-label">交易日/月:</label>
<div class="col-sm-4">
<input type="text" id="tranDate" name="tranDate" class="form-control Wdate" onfocus="selDate()" />
</div>
</div>
<div class="form-group form-group-sm">
<label for="Excelfile" class="col-sm-4 control-label">Excel文件:</label>
<div class="col-sm-4">
<input type="file" name="Excelfile" id="Excelfile" value="" />
</div>
</div> <div class="col-sm-offset-4">
<button type="submit" class="btn btn-primary btn-sm">
<i class="glyphicon glyphicon-saved"></i> 保存
</button>
<button onclick="back();" class="btn btn-sm btn-danger" type="button">
<i class="glyphicon glyphicon-remove-circle"></i> 取消
</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
<script src="My97DatePicker/WdatePicker.js"></script>
<script>
// 根据条件决定My97DatePicker日期控件弹出的日期格式
var bfjis=$('#bfjis').val();
$('#bfjis').change(function(){
bfjis = $('#bfjis').val();
// alert("1:"+bfjis)
})
function selDate(){
switch (bfjis) {
case "1":
WdatePicker({ dateFmt: 'yyyy-MM', minDate:'2016-1',maxDate:'2099-12',isShowToday: false, isShowClear: false, readOnly:true });
break ;
case "0":
WdatePicker({dateFmt: 'yyyyMMdd', readOnly:true});
break;
}
}
</script>
</body>
</html>