Js Code
Copy codeThe Code is as follows:
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 );
If (month = 2 ){
If (year % 4 = 0 & amp; 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 );
If (v_month = 12 & v_day> = 22)
| (V_month = 1 & v_day <= 20 )){
Return "Capricorn ";
}
Else if (v_month = 1 & v_day> = 21)
| (V_month = 2 & v_day <= 19 )){
Return "Aquarius ";
}
Else if (v_month = 2 & v_day> = 20)
| (V_month = 3 & v_day <= 20 )){
Return "Pisces ";
}
Else if (v_month = 3 & v_day> = 21)
| (V_month = 4 & v_day <= 20 )){
Return "Aries ";
}
Else if (v_month = 4 & v_day> = 21)
| (V_month = 5 & v_day <= 21 )){
Return "Taurus ";
}
Else if (v_month = 5 & v_day> = 22)
| (V_month = 6 & v_day <= 21 )){
Return "Gemini ";
}
Else if (v_month = 6 & v_day> = 22)
| (V_month = 7 & v_day <= 22 )){
Return "cancer ";
}
Else if (v_month = 7 & v_day> = 23)
| (V_month = 8 & v_day <= 23 )){
Return "Leo ";
}
Else if (v_month = 8 & v_day> = 24)
| (V_month = 9 & v_day <= 23 )){
Return "Virgo ";
}
Else if (v_month = 9 & v_day> = 24)
| (V_month = 10 & v_day <= 23 )){
Return "Libra ";
}
Else if (v_month = 10 & v_day> = 24)
| (V_month = 11 & v_day <= 22 )){
Return "scorpio ";
}
Else if (v_month = 11 & v_day> = 23)
| (V_month = 12 & v_day <= 21 )){
Return "Sagittarius ";
}
Return "";
}
Html
Copy codeThe Code is as follows:
<DIV> Date of Birth: </DIV>
<DIV>
<Asp: DropDownList ID = "DDL_Year" runat = "server" onchange = "birthdayOnchange (this);"> </asp: DropDownList> year
<Asp: DropDownList ID = "DDL_Month" runat = "server" onchange = "birthdayOnchange (this); adjustAstro ();"> </asp: DropDownList> month
<Asp: DropDownList ID = "DDL_Day" runat = "server" onchange = "adjustAstro ();"> </asp: DropDownList> day
</DIV>
<DIV> constellation: </DIV>
<DIV>
<SELECT id = astro disabled name = astro runat = "server">
<OPTION selected> Virgo </OPTION>
</SELECT>
</DIV>