• 年月日三下拉框联动 JS


     1 <html>
     2   <head>
     3   <title>年月日三下拉框联动 - www.aspxhome.com</title>
     4   <meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
     5   <meta name='author' content='F.R.Huang(meizz梅花雨)//www.meizz.com'>
     6   </head>
     7   <body onload="YYYYMMDDstart(document.form1,document.form1.SYear,document.form1.SMonth,document.form1.SDay),YYYYMMDDstart(document.form1,document.form1.EYear,document.form1.EMonth,document.form1.EDay)">
     8   <form name=form1>
     9    起始时间:
    10    <select name=SYear onchange="YYYYDD(this.value,document.form1.SMonth,document.form1.SDay)">
    11    <option value="">年</option>
    12    </select>13    <select name=SMonth onchange="MMDD(this.value,document.form1.SYear,document.form1.SDay)">
    14    <option value="">月</option>
    15    </select>16    <select name=SDay>
    17    <option value="">日</option>
    18    </select>日<br><br>
    19    完成时间:
    20    <select name=EYear onchange="YYYYDD(this.value,document.form1.EMonth,document.form1.EDay)">
    21    <option value="">年</option>
    22    </select>23    <select name=EMonth onchange="MMDD(this.value,document.form1.EYear,document.form1.EDay)">
    24    <option value="">月</option>
    25    </select>26    <select name=EDay>
    27    <option value="">日</option>
    28    </select>29   </form>
    30   <script language="JavaScript"><!--
    31   function YYYYMMDDstart(form,year,month,day)
    32   {
    33    MonHead = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    34    //先给年下拉框赋内容
    35    var y = new Date().getFullYear();
    36    for (var i = (y-3); i < (y+5); i++) //以今年为准,前30年,后30年
    37    year.options.add(new Option(i,i));
    38    //赋月份的下拉框
    39    for (var i = 1; i < 13; i++)
    40    month.options.add(new Option(i,i));
    41    year.value = y;
    42    month.value = new Date().getMonth() + 1;
    43    var n = MonHead[new Date().getMonth()];
    44    if (new Date().getMonth() ==1 && IsPinYear(year.options[year.selectedIndex].value)) n++;
    45    writeDay(n,day); //赋日期下拉框Author:meizz
    46    day.value = new Date().getDate();
    47   }
    48   function YYYYDD(str,month,day) //年发生变化时日期发生变化(主要是判断闰平年)
    49   {
    50    var MMvalue = month.options[month.selectedIndex].value;
    51    if (MMvalue == "" ){ var e = day; optionsClear(e); return;}
    52    var n = MonHead[MMvalue - 1];
    53    if (MMvalue ==2 && IsPinYear(str)) n++;
    54    writeDay(n,day)
    55   }
    56   function MMDD(str,year,day) //月发生变化时日期联动
    57   {
    58    var YYYYvalue = year.options[year.selectedIndex].value;
    59    if (YYYYvalue == "" ){ var e = day; optionsClear(e); return;}
    60    var n = MonHead[str - 1];
    61    if (str ==2 && IsPinYear(YYYYvalue)) n++;
    62    writeDay(n,day)
    63   }
    64   function writeDay(n,day) //据条件写日期的下拉框
    65   {
    66    var e = day; optionsClear(e);
    67    for (var i=1; i<(n+1); i++)
    68    e.options.add(new Option(i,i));
    69   }
    70   function IsPinYear(year)//判断是否闰平年
    71   { return(0 == year%4 && (year%100 !=0 || year%400 == 0));}
    72   function optionsClear(e)
    73   {
    74    for (var i=e.options.length; i>0; i--)
    75    e.remove(i);
    76   }
    77   function compDate(SY,SM,SD,EY,EM,ED)
    78   {
    79   }
    80   //--></script>
    81   </body>
    82   </html>

    本文来自博客园,作者:mushishi,转载请注明原文链接:https://www.cnblogs.com/mushishi/archive/2013/05/29/3105799.html

  • 相关阅读:
    goole的protoc文件[test_pb2.py]
    selenium中无页面基本配置
    连接数据库
    python计时器(打包exe即可)
    pip 升级 报No module named 'pip'错怎么处理-百度经验
    人脸识别之识别出某人并标记
    WIN7环境人脸检测及识别python实现系列(3)——为模型训练准备人脸数据
    安装pillow(python的图形界面库) PIL模块安装
    python 用pip安装cv2
    python调用摄像头拍照并保存
  • 原文地址:https://www.cnblogs.com/mushishi/p/3105799.html
Copyright © 2020-2023  润新知