首頁  >  文章  >  web前端  >  js日期、星座的級聯顯示程式碼_javascript技巧

js日期、星座的級聯顯示程式碼_javascript技巧

WBOY
WBOY原創
2016-05-16 17:02:561066瀏覽

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);

        if ((v_month == 12 && v_day >= 22)
  || (v_month == 1 &&        }
        else if ((v_month == 1 && v_day >= 21)
  || (v_month == 2 && v_day         else if ((v_month == 2 && v_day >= 20)
  || (v_month == 3 && v_day                  else if ((v_month == 3 && v_day >= 21)
  || (v_month == 4 && v_day               else if ( (v_month == 4 && v_day >= 21)
  || (v_month == 5 && v_day          v_month = = 5) && v_day >= 22)
  || (v_month == 6 && v_day             else if ((v_month == 6 && v_day > = 22)
  || (v_month == 7 && v_day            se if ((v_month == 7 && v_day > = 23)
  || (v_month == 8 && v_day             return "獅子座” month == 8 && v_day >= 24)
|| ( v_month == 9 && v_day             return "處女座";
      4)
  || ( v_month == 10 && v_day             return "天秤座";
       🎜>  || (v_month == 11 ) && v_day            return "天蠍座";
        }
  🎜>  || (v_month == 12 && v_day             return "射手座";
        }
   🎜>
html






複製程式碼


程式碼如下:


               
出生日期:

               
                   
               
               
星座:

               
           
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn