• jQuery:年月日三级联动


     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>
  • 相关阅读:
    用正则表达式简单加密(C#为例)
    新浪微博error:redirect_uri_mismatch的解决方法 [
    UITableView延伸:点击cell关闭键盘,加载不同cell,监听里面的textfeild内容改变
    iossharesdk微信登录出错
    关于IOS项目QQ空间授权提示安装最新版本的QQ的解决方法!
    如何解决 错误code signing is required for product type 'xxxxx' in SDK 'iOS 8.2'
    UITableView加载几种不同的cell
    iOS学习小结(一)
    开源中国+soucetree
    获取本机ip地址
  • 原文地址:https://www.cnblogs.com/zblc2016/p/6075164.html
Copyright © 2020-2023  润新知