日期:2014-05-16  浏览次数:20412 次

谁有JAVASCRIPT的日历代码
谁有用JAVASCRIPT的日历代码
就是点一个文本框出现日历,选择后在文本框内显示选择的日期格式为(yyyy-mm-dd)格式。

------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
</HEAD>

<BODY>
<input type= "text " style= "behavior:url( 'Date.htc '); ">
</BODY>
</HTML>

Date.htc:
<public:attach event=oncontentready onevent=initDate()>
<script>
//该HTC组件目前只支持INPUT并TYPE=TEXT下使用

//日期面板容器
var vDiv=null;
//框架
var vFieldset=null;
//日期面板
var vTable=null;
//日期格式字符串
var strDate= " ";

//静态数组
var strWeekArray=new Array( "星期日 ", "星期一 ", "星期二 ", "星期三 ", "星期四 ", "星期五 ", "星期六 ");

function initDate()
{
//初始化日期
if(element.value)
{strDate=element.value;}
else
{strDate=getToday();}
//创建容器
vDiv=document.createElement( "vDiv ");
vDiv.style.position= "absolute ";
vDiv.style.left=0;
vDiv.style.top=0;
vDiv.style.width= "275px ";
//绘制框架
vFieldset=document.createElement( "fieldset ");
var vLegend=document.createElement( "legend ");
vLegend.style.font= "normal 9pt 宋体 ";
vLegend.innerHTML= "日期 ";
vFieldset.appendChild(vLegend);
//绘制年月栏
initYearMonthBar();
//绘制面板
initPanel();
//绘制控制区
initConsole();

vDiv.appendChild(vFieldset);
window.document.body.insertAdjacentElement( "afterbegin ",vDiv);
vDiv.style.display= "none ";

//事件绑定
element.attachEvent( "onmousedown ",onMouseDown);
element.readOnly= "true ";
}
//绘制面板
function initPanel()
{
vTable=document.createElement( "table ");
vTable.style.backgroundColor= "#EEEEEE ";
vTable.border= "0 ";
vTable.cellSpacing= "1 ";
vTable.cellPadding= "0 ";
//vTable.width= "80% ";
vTable.style.borderLeft= "1px solid #000000 ";
vTable.style.borderBottom= "1px solid #000000 ";
initWeekCol();
initDayCell();
vFieldset.appendChild(vTable);
}
//画年月
function initYearMonthBar()
{
vInput=document.createElement( "input ");
vInput.type= "button ";
vInput.style.font= "normal 9pt Marlett ";
vInput.value= "3 ";
vFieldset.appendChild(vInput);
vSelect=document.createElement( "select ");
vSelect.style.font= "normal 8pt 宋体 ";
for(mIndex=eval( "getDateYear()-20 ");mIndex <=eval( "getDateYear()+20 ");mIndex++)
{
vOption=document.createElement( "option ");
vOption.value=mIndex;
vOption.text=mIndex+ "年 ";
vSelect.add(vOption);
if(getDateYear()==mIndex)
{
vOption.selected= "selected ";
}
}
vSelect.attachEvent( "onchange ",onYearChange);
vFieldset.appendChild(vSelect);
vInpu