当前位置: 首页 > 图文教程 > 网络编程 > Javascript > javascript版的日期输入控件(3)

Javascript
纯JS半透明Tip效果代码
JavaScript 读URL参数增强改进版版
JS对URL字符串进行编码/解码分析
javescript完整操作Table的增加行,删除行的列子大全
js可填可选的下拉框
prototype Element学习笔记(篇一)
prototype Element学习笔记(篇二)
prototype Element学习笔记(Element篇三)
Prototype使用指南之selector.js说明
不唐突的JavaScript的七条准则整理收集
js判断变量是否空值的代码
Firefox getBoxObjectFor getBoundingClientRect联系
Div自动滚动到末尾的代码
javascript笔试题目附答案
javascript引导程序
js身份证验证超强脚本
JS给元素注册事件的代码
JavaScript函数、方法、对象代码
JS写的数字拼图小游戏代码[学习参考]
关于B/S判断浏览器断开的问题讨论

Javascript 中的 javascript版的日期输入控件(3)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 281 ::
收藏到网摘: n/a

     displayCalendar(obj_month.innerText-1,obj_year.innerText);
  }

  function numberOfDays(month,year)  //取得每月天数,判断平年闰年
  {
    var numDays=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
    n=numDays[month];
    if(month==1&&year%4==0) ++n;
    return n;
  }

  function displayCalendar(month,year)
  {

    var d=new Date(year,month,1);
    var startDay=d.getDay();   //日期起始数字
    var numDays=numberOfDays(month,year);  //本月天数
 
    var day=document.getElementsByName("day");
    for(var i=0;i<day.length;i++)
    {
     day[i].innerText="";
    }
    for(var j=1;j<=numDays;j++)  //插入日期
    {
      day[startDay+j-1].innerText=j;
    }
 
  }
  function writeDate(n)
  {
     document.writeln("<H3 ALIGN='CENTER'>"+n+"</H3>");
   }

  function add_day(year,month,day)
  {
     bd.birthdate.value=year+"-"+month+"-"+day;
  }
  </script>
  </HEAD>

   <BODY>
  <form name="bd">
  <input type="text" name="birthdate" size="20" readOnly><input type="button" value="..." onclick="showdb()">
  </form>
  <div id="input_birth" name="input_birth" style="visibility:hidden; width:239; height:128">
  <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" style="cursor:hand" bordercolor="#111111" width="100%"  height="26">
    <tr>