js日期、星座的級聯(lián)顯示代碼
js 代碼
function birthdayOnchange(obj) {
var year = $("<%= DDL_Year.ClientID%>").value;
if (year == "year")
return;
else
year = parseInt(year, 10);
var month = $("<%=DDL_Month.ClientID%>").value;
if (month == "month")
return;
else
month = parseInt(month, 10);
var day = $("<%=DDL_Day.ClientID%>").value;
var wholeday = getDays(year, month);
if (1) {
var options = $("<%=DDL_Day.ClientID%>").options;
for (var i = 1; i <= wholeday; i++) {
var j = i.toString();
j = j.length == 1 ? "0" + j : j;
options.length = i + 1;
options[i].value = j;
options[i].text = j;
if (day <= wholeday && i == day) {
options[i].selected = true;
}
}
}
}
function getDays(year, month) {
var dayarr = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
if (month == 2) {
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0 || year < 1900)
return 29;
else
return dayarr[month - 1];
}
else {
return dayarr[month - 1];
}
}
function adjustAstro() {
var v_astro = getAstro($("<%=DDL_Month.ClientID%>").value, $("<%=DDL_Day.ClientID%>").value);
$("<%=astro.ClientID %>").options[0].text = v_astro;
}
function getAstro(v_month, v_day) {
v_month = parseInt(v_month, 10)
v_day = parseInt(v_day, 10);
html
<DIV>出生日期:</DIV>
<DIV>
<asp:DropDownList ID="DDL_Year" runat="server" onchange="birthdayOnchange(this);"></asp:DropDownList> 年
<asp:DropDownList ID="DDL_Month" runat="server" onchange="birthdayOnchange(this);adjustAstro();"></asp:DropDownList> 月
<asp:DropDownList ID="DDL_Day" runat="server" onchange="adjustAstro();"></asp:DropDownList> 日
</DIV>
相關(guān)文章
理解javascript中的Function.prototype.bind的方法
這篇文章主要介紹了理解javascript中的Function.prototype.bind的方法,具有一定參考價值,有興趣的可以了解一下。2017-02-02DLL+ ActiveX控件+WEB頁面調(diào)用例子
因項目需要,開始學(xué)習(xí)并研究VC、DLL及ActiveX控件,網(wǎng)上資料找了很多,但沒一個可用的或者說沒一個例子可理解并運行的。沒辦法,自己研究吧。功夫不負(fù)有心人,終有小成了,呵呵,現(xiàn)在把自己學(xué)習(xí)總結(jié)了一下,獻(xiàn)給需要的人。2010-08-08微信小程序wx.request實現(xiàn)后臺數(shù)據(jù)交互功能分析
這篇文章主要介紹了微信小程序wx.request實現(xiàn)后臺數(shù)據(jù)交互功能,分析微信小程序wx.request在后臺數(shù)據(jù)交互過程中遇到的問題與相關(guān)的解決方法,需要的朋友可以參考下2017-11-11jquery中click等事件綁定及移除的幾種方法小結(jié)
這篇文章主要介紹了jquery中綁定事件與解綁事件是常用到的寫法,這里總結(jié)了幾種常見的綁定事件與解綁事件的方法,需要的朋友可以參考下2023-05-05