年月日控件

<select id="Year" name="Year" class="sys_selectB mr10">
</select>
<select id="Month" name="Month" class="sys_selectB mr10">
</select>
<select id="Day" name="Day" class="sys_selectB mr10">
</select>

  


$("#City").change(function () {
if ($("#City").val() != "0")
Biz.Customer.Register.buildWarningMessage(jQuery("#City"), 0);
});
for (var y = 2014; y > 1960; y--) {
$("#Year").append(jQuery("<option></option>").val(y).html(y));
}
for (var m = 1; m < 13; m++) {
$("#Month").append(jQuery("<option></option>").val(m).html(m));
}
InitDays($("#Year").val(), $("#Month").val());
$("#Year,#Month").bind("change", function () {
InitDays($("#Year").val(), $("#Month").val());
}); 

function TGetDaysInMonth(iMonth, iYear) {
var dPrevDate = new Date(iYear, iMonth, 0);
return dPrevDate.getDate();
}
function InitDays(iYear, iMonth) {
var dDate = new Date(),
daysInMonth = TGetDaysInMonth(iMonth, iYear),
str = "";
$("#Day").empty();
for (var d = 1; d <= parseInt(daysInMonth); d++) {
if (d == dDate.getDate()) {
str = "<option value=" + d + " selected=true>" + d + "</option>";
} else {
str = "<option value=" + d + ">" + d + "</option>";
}
$("#Day").append(str);
}
} 

  

posted @ 2014-04-11 09:32  Care健康  阅读(372)  评论(0编辑  收藏  举报
版权
作者:Bober Song

出处:http://bober.cnblogs.com

Care健康:http://www.aicareyou.com

推荐空间:华夏名网

本文首发博客园,版权归作者跟博客园共有。

转载必须保留本段声明,并在页面显著位置给出本文链接,否则保留追究法律责任的权利。