当前位置: 首页 > 图文教程 > 网页制作 > HTML/XHTML教程 > 最精致的日历式日期输入控件

HTML/XHTML教程
理解表现和结构相分离
HTML语言剖析(一)Html简介
HTML语言剖析(二)HTML标记一览
HTML语言剖析(三)文件标记
HTML语言剖析(四)排版标记
HTML语言剖析(五)字体标记
HTML语言剖析(六)清单标记
采访Eric Meyer的10个问题
Flash页面如何通过校验
为什么要抛弃HTML
典型的三行二列居中高度自适应布局
盒模型bug的解决方法
用!important解决IE和Mozilla的布局差别
使用DIV之后,什么时候使用TABLE
同一个页面用多个id有什么影响
定义标题的最好方法
左中右3栏布局中最先显示中栏内容的方法
alt属性和title属性
在IE中为abbr标签加样式
HTML4标签的默认样式列表

HTML/XHTML教程 中的 最精致的日历式日期输入控件


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

<HTML>
<HEAD>
<TITLE>最精致的日历式日期输入控件 (Smart Ver 1.00)</TITLE>
</HEAD>
<style>
body
{
 font-size:12px;
 font-family:"Tahoma";
}
td
{
 font-size:12px;
 font-family:"Tahoma";
}
.inputdate
{
 border:1px solid #7287c6;
 text-align: center;
 font-size: 12px;
 font-style: normal;
 height: 16px;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
/********************************************************************
more javascript from http://www.smallrain.net
时间:2004-01-01
作者:Smart
功能:日历式日期选择控件
 
参数:
说明:
1.输入框直接调用用以下代码
<Script>DateBox("InputName","DateValue")<\/Script>
其中:InputName 为输入日期的文本框.注:不能为空.
       DateValue  为输入日期的文本框默认日期值.格式为:YYYY-MM-DD.如2004-01-01
                       此值可以不填或为空.则默认值为当天日期.(客户端)
2.其它"按钮"调用用以下代码
CallDate("InputName")
其中:InputName 为输入日期的文本框.注:不能为空.
修改区
时间:
修改人:
原因:
********************************************************************/
/*基本参数*/
var Frw=106; //日历宽度
var Frh=137; //日历高度
var Frs=4;     //影子大小
var Hid=true;//日历是否打开
/*创建框架*/
document.writeln('<Div id=Calendar Author=smart  scrolling="no" frameborder=0 style="border:0px solid #EEEEEE ;position: absolute; width: '+Frw+'; height: '+Frh+'; z-index: 0; filter :\'progid:DXImageTransform.Microsoft.Shadow(direction=135,color=#AAAAAA,strength='+Frs+')\' ;display: none"></Div>');
/*取得今日日期*/
function GetTodayDate()
{
   today= new Date();
   y= today.getYear();
   m= (today.getMonth() + 1);
   if (m<10)
   {
     m='0'+m;
   }
   d= today.getDate();
   if (d<10)
   {
     d='0'+d;
   }
return y+'-'+m+'-'+d
}
/*输入今天日期*/
function SetTodayDate(InputBox)
{
  HiddenCalendar();
  InputBox.value=GetTodayDate();
}
/*取某年某月第一天的星期值(月份-1)*/
function GetFirstWeek(The_Year,The_Month)
{
  return (new Date(The_Year,The_Month-1,1)).getDay()
}
/*取某年某月中总天数*/
function GetThisDays(The_Year,The_Month)
{
  return (new Date(The_Year,The_Month,0)).getDate()
}
/*取某年某月上个月中总天数*/
function GetLastDays(The_Year,The_Month)
{
  return (new Date(The_Year,The_Month-1,0)).getDate()
}
/*判断是否是闰年*/
function RunNian(The_Year)
{
 if ((The_Year%400==0) || ((The_Year%4==0) && (The_Year%100!=0)))
  return true;
 else
  return false;
}
/* 判断日期(YYYY-MM-DD)的日期是否正确 */
function DateIsTrue(asDate){
 var lsDate  = asDate + "";
 var loDate  = lsDate.split("-");
 if (loDate.length!=3) return false;
 var liYear  = parseFloat(loDate[0]);
 var liMonth = parseFloat(loDate);
 var liDay   = parseFloat(loDate);
 if ((loDate[0].length>4)||(loDate.length>2)||(loDate.length>2)) return false;
 if (isNaN(liYear)||isNaN(liMonth)||isNaN(liDay)) return false;
 if ((liYear<1800)||(liYear>2500)) return false;
 if ((liMonth>12)||(liMonth<=0))   return false;
 if (GetThisDays(liYear,liMonth)<liDay) return false;
 return !isNaN(Date.UTC(liYear,liMonth,liDay));
}
/*取某年某月的周值*/
function GetCountWeeks(The_Year,The_Month)
{
 var Allday;
 Allday = 0;
 if (The_Year>2000)
 {
&nbs