jquery時間日期三級聯動

來源:互聯網
上載者:User

標籤:ext   get   drop   www   default   list   text   lis   change   

 1 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %> 2  3 <!DOCTYPE html> 4  5 <html xmlns="http://www.w3.org/1999/xhtml"> 6 <head runat="server"> 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 8     <script src="js/jquery-1.7.2.min.js"></script> 9     <title></title>10 </head>11 <body>12     <form id="form1" runat="server">13     <div>14         <asp:DropDownList ID="dr_year" runat="server"></asp:DropDownList>年15         <asp:DropDownList ID="dr_month" runat="server"></asp:DropDownList>月16         <asp:DropDownList ID="dr_day" runat="server"></asp:DropDownList>日17     </div>18     </form>19 </body>20 </html>21 <script>22     var days = 0;23     years();24     months();25     Days();26     var date = new Date();27     $("#dr_year").val(date.getFullYear());28     $("#dr_month").val((date.getMonth() + 1));29     $("#dr_day").val(date.getDate());30     $("#dr_year").change(function () {31         months();32         Days();33     });34 35     $("#dr_month").change(function () {36         Days();37     });38     function years()39     {40         for(var i=1900;i<=2100;i++)41         {42             var str = "<option value=\"" + i + "\">" + i+ "</option>";43             $("#dr_year").append(str);44         }45     }46     function months() {47         $("#dr_month").empty();48         for (var i = 1; i <= 12; i++) {49             var str = "<option value=\"" + i + "\">" + i + "</option>";50             $("#dr_month").append(str);51         }52     }53     function Days() {54         $("#dr_day").empty();55         if (parseInt($("#dr_month").val()) == 1 || parseInt($("#dr_month").val()) == 3 || parseInt($("#dr_month").val()) == 5 || parseInt($("#dr_month").val()) == 7 || parseInt($("#dr_month").val()) == 8 || parseInt($("#dr_month").val()) == 10 || parseInt($("#dr_month").val()) == 12) {56             days = 31;57         }58         else if (parseInt($("#dr_month").val()) == 4 || parseInt($("#dr_month").val()) == 6 || parseInt($("#dr_month").val()) == 9 || parseInt($("#dr_month").val()) == 11) {59             days = 30;60         }61         else {62             if (parseInt($("#dr_year").val()) % 400 == 0 || (parseInt($("#dr_year").val()) % 4 == 0 && parseInt($("#dr_year").val()) % 100 != 0)) {63                 days = 29;64             }65             else {66                 days = 28;67             }68         }69         for (var i = 1; i <= days; i++) {70             var str = "<option value=\"" + i + "\">" + i + "</option>";71             $("#dr_day").append(str);72         }73     }74 </script>

 

jquery時間日期三級聯動

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.