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)文章
checkbox設(shè)置復(fù)選框的只讀效果不讓用戶勾選
有時候是只想告知用戶這個地方是可以進(jìn)行勾選操作的而不想讓用戶在此處勾選(比如在信息展示頁面),這時候就需要將復(fù)選框設(shè)置成只讀的效果,具體實現(xiàn)方法如下2013-08-08
JS字符串轉(zhuǎn)換為數(shù)組的4 個方法示例小結(jié)
這篇文章主要介紹了JS字符串轉(zhuǎn)換為數(shù)組的4 個方法示例小結(jié),本文通過示例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧2023-12-12

