一个不错的日历选择框(有两个,一个只有日期,另外一个日期时间都有)

第一个:

us.js

//////////////////////////////
// UncCalendar 1.0 //
// Author: Zhong@UNC //
// E-mail: [email protected] //
// 06/01/2004 //
//////////////////////////////

function UncCalendar (sName, sDate)
{
/////////////////////////////////////////////////////////////////////////
//定义UncCalendar对象的属性并赋默认值。
//inputValue属性的值为"today"时表示(客户机)当前日期。
//直接在这里把默认值修改成你想要的,使用时你就什么也不用设置了。
this.inputName = sName || "uncDate";
this.inputValue = sDate || "";
this.inputSize = 10;
this.inputClass = "";
this.color = "#333333";
this.bgColor = "#EEEEEE";
this.buttonWidth = 60;
this.buttonWords = "选择日期";
this.canEdits = true;
this.hidesSelects = true;
/////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////
//定义display方法。
this.display = function ()
{
var reDate = /^(19[7-9]\d|20[0-5]\d)\-(0?\d|1[0-2])\-([0-2]?\d|3[01])$/;
if (reDate.test(this.inputValue))
{
var dates = this.inputValue.split("-");
var year = parseInt(dates[0], 10);
var month = parseInt(dates[1], 10);
var mday = parseInt(dates[2], 10);
}
else
{
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth()+1;
var mday = today.getDate();
}
if (this.inputValue == "today")
inputValue = year + "-" + month + "-" + mday;
else
inputValue = this.inputValue;
var lastDay = new Date(year, month, 0);
lastDay = lastDay.getDate();
var firstDay = new Date(year, month-1, 1);
firstDay = firstDay.getDay();

var btnBorder =
"border-left:1px solid " + this.color + ";" +
"border-right:1px solid " + this.color + ";" +
"border-top:1px solid " + this.color + ";" +
"border-bottom:1px solid " + this.color + ";";
var btnStyle =
"padding-top:3px;cursor:default;width:" + this.buttonWidth + "px;text-align:center;height:18px;top:-9px;" +
"font:normal 12px 宋体;position:absolute;z-index:99;background-color:" + this.bgColor + ";" +
"line-height:12px;" + btnBorder + "color:" + this.color + ";";
var boardStyle =
"position:absolute;width:1px;height:1px;background:" + this.bgColor + ";top:8px;border:1px solid "+
this.color + ";display:none;padding:3px;";
var buttonEvent =
" onmouseover=\"this.childNodes[0].style.borderBottom='0px';" +
"this.childNodes[1].style.display='';this.style.zIndex=100;" +
(this.hidesSelects ?
"var slts=document.getElementsByTagName('SELECT');" +
"for(var i=0;i<slts.length;i++)slts[i].style.visibility='hidden';"
: "") + "\"" +
" onmouseout=\"this.childNodes[0].style.borderBottom='1px solid " + this.color + "';" +
"this.childNodes[1].style.display='none';this.style.zIndex=99;" +
(this.hidesSelects ?
"var slts=document.getElementsByTagName('SELECT');" +
"for(var i=0;i<slts.length;i++)slts[i].style.visibility='';"
: "") + "\"" +
" onselectstart=\"return false;\"";
var mdayStyle = "font:normal 9px Verdana,Arial,宋体;line-height:12px;cursor:default;color:" + this.color;
var weekStyle = "font:normal 12px 宋体;line-height:15px;cursor:default;color:" + this.color;
var arrowStyle = "font:bold 7px Verdana,宋体;cursor:hand;line-height:16px;color:" + this.color;
var ymStyle = "font:bold 12px 宋体;line-height:16px;cursor:default;color:" + this.color;
var changeMdays =
"var year=parseInt(this.parentNode.cells[2].childNodes[0].innerText);" +
"var month=parseInt(this.parentNode.cells[2].childNodes[2].innerText);" +
"var firstDay=new Date(year,month-1,1);firstDay=firstDay.getDay();" +
"var lastDay=new Date(year,month,0);lastDay=lastDay.getDate();" +
"var tab=this.parentNode.parentNode, day=1;" +
"for(var row=2;row<8;row++)" +
" for(var col=0;col<7;col++){" +
" if(row==2&&col<firstDay){" +
" tab.rows[row].cells[col].innerHTML='&nbsp;';" +
" tab.rows[row].cells[col].isDay=0;}" +
" else if(day<=lastDay){" +
" tab.rows[row].cells[col].innerHTML=day;" +
" tab.rows[row].cells[col].isDay=1;day++;}" +
" else{" +
" tab.rows[row].cells[col].innerHTML='';" +
" tab.rows[row].cells[col].isDay=0;}" +
" }";
var pyEvent =
" onclick=\"var y=this.parentNode.cells[2].childNodes[0];y.innerText=parseInt(y.innerText)-1;" +
changeMdays + "\"";
var pmEvent =
" onclick=\"var y=this.parentNode.cells[2].childNodes[0];m=this.parentNode.cells[2].childNodes[2];" +
"m.innerText=parseInt(m.innerText)-1;if(m.innerText=='0'){m.innerText=12;y.innerText=" +
"parseInt(y.innerText)-1;}" + changeMdays + "\"";
var nmEvent =
" onclick=\"var y=this.parentNode.cells[2].childNodes[0];m=this.parentNode.cells[2].childNodes[2];" +
"m.innerText=parseInt(m.innerText)+1;if(m.innerText=='13'){m.innerText=1;y.innerText=" +
"parseInt(y.innerText)+1;}" + changeMdays + "\"";
var nyEvent =
" onclick=\"var y=this.parentNode.cells[2].childNodes[0];y.innerText=parseInt(y.innerText)+1;" +
changeMdays + "\"";
var mdayEvent =
" onmouseover=\"if(event.srcElement.tagName=='TD'&&event.srcElement.isDay){" +
"event.srcElement.style.backgroundColor='" + this.color + "';" +
"event.srcElement.style.color='" + this.bgColor + "';" +
"event.srcElement.style.cursor='hand';" +
"var ym=event.srcElement.parentNode.parentNode.rows[0].cells[2].childNodes;" +
"event.srcElement.title=ym[0].innerText+'-'+ym[2].innerText+'-'+event.srcElement.innerText;}\"" +
" onmouseout=\"if(event.srcElement.tagName=='TD'&&event.srcElement.isDay){" +
"event.srcElement.style.backgroundColor='" + this.bgColor + "';" +
"event.srcElement.style.color='" + this.color + "';" +
"event.srcElement.style.cursor='default';" +
"var ym=event.srcElement.parentNode.parentNode.rows[0].cells[2].childNodes;" +
"event.srcElement.title=ym[0].innerText+'-'+ym[2].innerText+'-'+event.srcElement.innerText;}\"" +
" onclick=\"if(event.srcElement.tagName=='TD'&&event.srcElement.isDay){" +
"var inp=this.parentNode.parentNode.parentNode.previousSibling.childNodes[0];" +
"inp.value=this.rows[0].cells[2].childNodes[0].innerText+'-'+this.rows[0].cells[2].childNodes[2]." +
"innerText+'-'+event.srcElement.innerText;" +
"this.parentNode.style.display='none';this.parentNode.parentNode.style.zIndex=99;" +
"this.parentNode.previousSibling.style.borderBottom='1px solid " + this.color + "';" +
(this.hidesSelects ?
"var slts=document.getElementsByTagName('SELECT');" +
"for(var i=0;i<slts.length;i++)slts[i].style.visibility='';"
: "") + "}\"";

var output = "";
output += "<table cellpadding=0 cellspacing=1 style='display:inline;'><tr>";
output += " <td><input size=" + this.inputSize + " maxlength=10 value=\"" + inputValue + "\"";
output += (this.canEdits ? "" : " readonly") + " name=\"" + this.inputName + "\"></td>";
output += " <td width=" + this.buttonWidth + ">";
output += " <div style=\"position:absolute;overflow:visible;width:0px;height:0px;\"" + buttonEvent + ">";
output += " <div style=\"" + btnStyle + "\"><nobr>" + this.buttonWords + "</nobr></div>";
output += " <div style=\"" + boardStyle + "\">";
output += " <table cellspacing=1 cellpadding=1 width=175" + mdayEvent + ">";
output += " <tr height=20 align=center>";
output += " <td style=\"" + arrowStyle + "\" title=\"上一年\"" + pyEvent + ">&lt;&lt;</td>";
output += " <td style=\"" + arrowStyle + "\" align=left title=\"上个月\"" + pmEvent + ">&lt;</td>";
output += " <td colspan=3 style=\"" + ymStyle + "\" valign=bottom>";
output += " <span>" + year + "</span><span>年</span><span>" + month + "</span><span>月</span>";
output += " </td>";
output += " <td style=\"" + arrowStyle + "\" align=right title=\"下个月\"" + nmEvent + ">&gt;</td>";
output += " <td style=\"" + arrowStyle + "\" title=\"下一年\"" + nyEvent + ">&gt;&gt;</td>";
output += " </tr>";
output += " <tr height=20 align=center bgcolor=" + this.bgColor + ">";
output += " <td width=14% style=\"" + weekStyle + "\">日</td>";
output += " <td width=14% style=\"" + weekStyle + "\">一</td>";
output += " <td width=14% style=\"" + weekStyle + "\">二</td>";
output += " <td width=14% style=\"" + weekStyle + "\">三</td>";
output += " <td width=14% style=\"" + weekStyle + "\">四</td>";
output += " <td width=14% style=\"" + weekStyle + "\">五</td>";
output += " <td width=14% style=\"" + weekStyle + "\">六</td>";
output += " </tr>";
var day = 1;
for (var row=0; row<6; row++)
{
output += "<tr align=center>";
for (var col=0; col<7; col++)
{
if (row == 0 && col < firstDay)
output += "<td style=\"" + mdayStyle + "\">&nbsp;</td>";
else if (day <= lastDay)
{
output += "<td style=\"" + mdayStyle + "\" isDay=1>" + day + "</td>";
day++;
}
else
output += "<td style=\"" + mdayStyle + "\"></td>";
}
output += "</tr>";
}
output += " </table>";
output += " </div>";
output += " </div>";
output += " </td>";
output += "</tr></table>";
document.write(output);
}
/////////////////////////////////////////////////////////////////////////
}

test.html

script src=uc.js></script>
<script language=javascript>
//拿过来就可以用,很简单。
//实例化时第一个参数是input的name;第二个参数是value,设为"today"就是当天。
var date1 = new UncCalendar ("date", "2008-08-08");
date1.display();
</script>
<br><br>
<script language=javascript>
//有一些属性,可以灵活的定制。
//事实上直接到uc.js中修改默认属性值使用起来会更方便一些,里面有注释。
var date2 = new UncCalendar ();
date2.inputName = "date"; //input的name。
date2.inputValue = "today"; //你会看到,input中将显示客户机系统当前时间。
date2.inputSize = 10; //input的size
date2.inputClass = ""; //input的class,这样你就能自己控制input的样式。
date2.color = "#000080"; //选择按钮、面板的边框以及日历中字的颜色。
date2.bgColor = "#EEEEFF"; //选择按钮、面板的背景色。
date2.buttonWidth = 60; //按钮宽度
date2.buttonWords = "选择日期"; //按钮显示的文字。
date2.canEdits = false; //input是否可以输入
date2.hidesSelects = true; //显增日期选择面板时是否隐藏页面中的select控件。
date2.display();
</script>

第二个:

test.html

<html>
<head>
<title>新增任务工单</title>
<script language="javascript" src="table_calendar.js"></script>/head>

<body >
<form name="TasksheetMainForm" >

<SCRIPT language=javascript>
<!--
//以下四行用于日历显示
var outObject;
var old_dd = null;
writeCalender();
bltSetDay(bltTheYear,bltTheMonth);
//-->
</SCRIPT>
<input type="text" name="endAcceptLimit" size="20" value="2006-04-15 00:00:00" onfocus="setday(this)" readonly="readonly">
</form>
</body>

</html>

下面是 table_calendar.js


function writeCalender(){
document.writeln('<div id=bltDateLayer style="position: absolute; width: 142; height: 166; z-index: 9998; display: none">');
document.writeln('<iframe src="javascript:false" style="position:absolute; visibility:inherit; top:0px; left:0px; width:142px; height:255px; z-index:-1;filter=\'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)\';"></iframe>');
document.writeln('<span id=tmpSelectYearLayer style="z-index: 9999;position: absolute;top: 2; left: 18;display: none"></span>');
document.writeln('<span id=tmpSelectMonthLayer style="z-index: 9999;position: absolute;top: 2; left: 75;display: none"></span>');
document.writeln('<table border=0 cellspacing=1 cellpadding=0 width=142 height=160 bgcolor=#808080 onselectstart="return false">');
document.writeln(' <tr><td width=142 height=23 bgcolor=#FFFFFF><table border=0 cellspacing=1 cellpadding=0 width=140 height=23>');
document.writeln(' <tr align=center><td width=20 align=center bgcolor=#808080 style="font-size:12px;cursor: hand;color: #FFD700" ');
document.writeln(' onclick="bltPrevM()" title="向前翻一月" Author=blt><b Author=blt>&lt;&lt;</b>');
document.writeln(' </td><td width=100 align=center style="font-size:12px;cursor:default" Author=blt>');
document.writeln(' <span Author=blt id=bltYearHead onclick="tmpSelectYearInnerHTML(this.innerText)"></span>&nbsp;年&nbsp;<span');
document.writeln(' id=bltMonthHead Author=blt onclick="tmpSelectMonthInnerHTML(this.innerText)"></span>&nbsp;月</td>');
document.writeln(' <td width=20 bgcolor=#808080 align=center style="font-size:12px;cursor: hand;color: #FFD700" ');
document.writeln(' onclick="bltNextM()" title="往后翻一月" Author=blt><b Author=blt>&gt;&gt;</b></td></tr>');
document.writeln(' </table></td></tr>');
document.writeln(' <tr><td width=142 height=18 bgcolor=#808080>');
document.writeln('<table border=0 cellspacing=0 cellpadding=0 width=140 height=1 style="cursor:default">');
document.writeln('<tr align=center><td style="font-size:12px;color:#FFFFFF" Author=blt>日</td>');
document.writeln('<td style="font-size:12px;color:#FFFFFF" Author=blt>一</td><td style="font-size:12px;color:#FFFFFF" Author=blt>二</td>');
document.writeln('<td style="font-size:12px;color:#FFFFFF" Author=blt>三</td><td style="font-size:12px;color:#FFFFFF" Author=blt>四</td>');
document.writeln('<td style="font-size:12px;color:#FFFFFF" Author=blt>五</td><td style="font-size:12px;color:#FFFFFF" Author=blt>六</td></tr>');
document.writeln('</table></td></tr><!-- Author:F.R.Huang(blt) http://www.blt.com/ mail: [email protected] 2002-10-8 -->');
document.writeln(' <tr><td width=142 height=120>');
document.writeln(' <table border=0 cellspacing=1 cellpadding=0 width=140 height=120 bgcolor=#FFFFFF Author=blt> ');
var n=0; for (j=0;j<6;j++){ document.writeln (' <tr align=center>'); for (i=0;i<7;i++){
document.writeln('<td width=20 height=20 id=bltDay'+n+' style="font-size:12px" Author=blt onclick=bltDayClick(this.innerText,this)></td>');n++;}
document.writeln('</tr>');}
document.writeln(' <tr align=center>');
document.writeln(' <td align=center colspan=4 Author=blt >');
document.writeln(' <select name="m_hour" Author=blt>');
for( j = 0; j < 24; j++ )
{
if( j < 10 )
document.writeln(' <option value="0' + j + '">' + j + '</option>');
else
document.writeln(' <option value="' + j + '">' + j + '</option>');
}
document.writeln(' </select>时</td>');
document.writeln(' <td align=center colspan=4 Author=blt>');
document.writeln(' <select name="m_min" Author=blt>');
for( j = 0; j < 60; j++ )
{
if( j < 10 )
document.writeln(' <option value="0' + j + '">' + j + '</option>');
else
document.writeln(' <option value="' + j + '">' + j + '</option>');
}
document.writeln(' </select>分');
document.writeln(' </td></tr>');
document.writeln(' <tr>');
document.writeln(' <td colspan=4 align=center Author=blt>');
document.writeln(' <Label onclick=setDayTime()>确 定</Label>');
document.writeln(' </td>');

document.writeln(' <td colspan=4 align=center Author=blt>');
document.writeln(' <Label onclick=closeLayer()>取 消</Label>');
document.writeln(' &nbsp;</td></tr>');
document.writeln(' </table></td></tr><tr><td>');
document.writeln(' <table border=0 cellspacing=1 cellpadding=0 width=100% bgcolor=#FFFFFF>');
document.writeln(' <tr><td Author=blt align=left><Label Author=blt title="向前翻一年" onclick="bltPrevY()" ');
document.writeln(' onfocus="this.blur()">< </Label> <Label Author=blt title="向前翻一月" ');
document.writeln(' onclick="bltPrevM()" onfocus="this.blur()"><<</Label></td><td ');
document.writeln(' Author=blt align=center><Label Author=blt onclick="bltToday()" ');
document.writeln(' onfocus="this.blur()" title="现在的年月">今 天</Label></td><td ');
document.writeln(' Author=blt align=right><Label Author=blt onclick="bltNextM()" ');
document.writeln(' onfocus="this.blur()" title="往后翻一月">>></Label> <Label ');
document.writeln(' Author=blt title="往后翻一年" onclick="bltNextY()"');
document.writeln(' onfocus="this.blur()"> ></Label></td>');
document.writeln('</tr></table></td></tr></table></div>');
}

function setday(tt,obj) //主调函数
{
if (arguments.length > 2){alert("对不起!传入本控件的参数太多!");return;}
if (arguments.length == 0){alert("对不起!您没有传回本控件任何参数!");return;}
var dads = document.all.bltDateLayer.style;var th = tt;
var ttop = tt.offsetTop; //TT控件的定位点高
var thei = tt.clientHeight; //TT控件本身的高
var tleft = tt.offsetLeft; //TT控件的定位点宽
var ttyp = tt.type; //TT控件的类型
while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;}
dads.top = (ttyp=="image")? ttop+thei : ttop+thei+6;
dads.left = tleft;
outObject = (arguments.length == 1) ? th : obj;
dads.display = '';
event.returnValue=false;
}
function setday1(tt,h,w) //主调函数 //modified by tianzhiquan for TawRmUser.add ->entry.jsp
{
if (arguments.length > 3){alert("对不起!传入本控件的参数太多!");return;}
if (arguments.length == 0){alert("对不起!您没有传回本控件任何参数!");return;}
var dads = document.all.bltDateLayer.style;var th = tt;
var ttop = tt.offsetTop; //TT控件的定位点高
var thei = tt.clientHeight; //TT控件本身的高
var tleft = tt.offsetLeft; //TT控件的定位点宽
var ttyp = tt.type; //TT控件的类型
while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;}
dads.top = (ttyp=="image")? ttop+thei : ttop+thei-h;
dads.left = tleft+w;
outObject = th;
dads.display = '';
event.returnValue=false;
}
var MonHead = new Array(12); //定义阳历中每个月的最大天数
MonHead[0] = 31; MonHead[1] = 28; MonHead[2] = 31; MonHead[3] = 30; MonHead[4] = 31; MonHead[5] = 30;
MonHead[6] = 31; MonHead[7] = 31; MonHead[8] = 30; MonHead[9] = 31; MonHead[10] = 30; MonHead[11] = 31;

var bltTheYear=new Date().getFullYear(); //定义年的变量的初始值
var bltTheMonth=new Date().getMonth()+1; //定义月的变量的初始值
var bltTheHour=new Date().getHours(); //定义时的变量的初始值 added by tianzhiquan
var bltTheMinute=new Date().getMinutes();//定义分的变量的初始值 added by tianzhiquan
var bltTheDay =new Date().getDate(); //定义日的变量的初始值 added by tianzhiquan
var bltWDay=new Array(37); //定义写日期的数组
var m_yy, m_mm, m_dd;
function document.onclick() //任意点击时关闭该控件
{
return;
with(window.event.srcElement)
{ if (tagName != "INPUT" && getAttribute("Author")==null)
document.all.bltDateLayer.style.display="none";
}
}

function bltWriteHead(yy,mm,hh,ms) //往 head 中写入当前的年与月
{ document.all.bltYearHead.innerText = yy;
document.all.bltMonthHead.innerText = mm;
}
function bltWriteHead1(yy,mm,hh,ms) //往 head 中写入当前的年与月,时与分 modified by tianzhiquan
{ document.all.bltYearHead.innerText = yy;
document.all.bltMonthHead.innerText =mm;
document.all.m_hour.value = hh;
document.all.m_min.value = ms;
}
function tmpSelectYearInnerHTML(strYear) //年份的下拉框
{
if (strYear.match(/\D/)!=null){alert("年份输入参数不是数字!");return;}
var m = (strYear) ? strYear : new Date().getFullYear();
if (m < 1000 || m > 9999) {alert("年份值不在 1000 到 9999 之间!");return;}
var n = m - 10;
if (n < 1000) n = 1000;
if (n + 26 > 9999) n = 9974;
var s = "<select Author=blt name=tmpSelectYear style='font-size: 12px' "
s += "onblur='document.all.tmpSelectYearLayer.style.display=\"none\"' "
s += "onchange='document.all.tmpSelectYearLayer.style.display=\"none\";"
s += "bltTheYear = this.value; bltSetDay(bltTheYear,bltTheMonth)'>\r\n";
var selectInnerHTML = s;
for (var i = n; i < n + 26; i++)
{
if (i == m)
{selectInnerHTML += "<option value='" + i + "' selected>" + i + "年" + "</option>\r\n";}
else {selectInnerHTML += "<option value='" + i + "'>" + i + "年" + "</option>\r\n";}
}
selectInnerHTML += "</select>";
document.all.tmpSelectYearLayer.style.display="";
document.all.tmpSelectYearLayer.innerHTML = selectInnerHTML;
document.all.tmpSelectYear.focus();
}

function tmpSelectMonthInnerHTML(strMonth) //月份的下拉框
{
if (strMonth.match(/\D/)!=null){alert("月份输入参数不是数字!");return;}
var m = (strMonth) ? strMonth : new Date().getMonth() + 1;
var s = "<select Author=blt name=tmpSelectMonth style='font-size: 12px' "
s += "onblur='document.all.tmpSelectMonthLayer.style.display=\"none\"' "
s += "onchange='document.all.tmpSelectMonthLayer.style.display=\"none\";"
s += "bltTheMonth = this.value; bltSetDay(bltTheYear,bltTheMonth)'>\r\n";
var selectInnerHTML = s;
for (var i = 1; i < 13; i++)
{
if (i == m)
{selectInnerHTML += "<option value='"+i+"' selected>"+i+"月"+"</option>\r\n";}
else {selectInnerHTML += "<option value='"+i+"'>"+i+"月"+"</option>\r\n";}
}
selectInnerHTML += "</select>";
document.all.tmpSelectMonthLayer.style.display="";
document.all.tmpSelectMonthLayer.innerHTML = selectInnerHTML;
document.all.tmpSelectMonth.focus();
}

function closeLayer() //这个层的关闭
{
document.all.bltDateLayer.style.display="none";
}

function document.onkeydown()
{
if (window.event.keyCode==27)document.all.bltDateLayer.style.display="none";
}

function IsPinYear(year) //判断是否闰平年
{
if (0==year%4&&((year%100!=0)||(year%400==0))) return true;else return false;
}

function GetMonthCount(year,month) //闰年二月为29天
{
var c=MonHead[month-1];if((month==2)&&IsPinYear(year)) c++;return c;
}

function GetDOW(day,month,year) //求某天的星期几
{
var dt=new Date(year,month-1,day).getDay()/7; return dt;
}

function bltPrevY() //往前翻 Year
{
if(bltTheYear > 999 && bltTheYear <10000){bltTheYear--;}
else{alert("年份超出范围(1000-9999)!");}
bltSetDay(bltTheYear,bltTheMonth);
}
function bltNextY() //往后翻 Year
{
if(bltTheYear > 999 && bltTheYear <10000){bltTheYear++;}
else{alert("年份超出范围(1000-9999)!");}
bltSetDay(bltTheYear,bltTheMonth);
}
function bltToday() //Today Button
{
bltTheYear = new Date().getFullYear();
bltTheMonth = new Date().getMonth()+1;
bltSetDay(bltTheYear,bltTheMonth);
_day =new Date().getDate(); //BEGIN: added by tianzhiquan
if ( _day < 10 )
{
m_dd = "0" +_day;
}
else
{
m_dd = "" + _day;
}
m_yy=bltTheYear;
if (bltTheMonth < 10)
{
m_mm = "0" +bltTheMonth;
}
else
{
m_mm = "" + bltTheMonth;
}
//END: added by tianzhiquan
}
function bltPrevM() //往前翻月份
{
if(bltTheMonth>1){bltTheMonth--}else{bltTheYear--;bltTheMonth=12;}
bltSetDay(bltTheYear,bltTheMonth);
}
function bltNextM() //往后翻月份
{
if(bltTheMonth==12){bltTheYear++;bltTheMonth=1}else{bltTheMonth++}
bltSetDay(bltTheYear,bltTheMonth);
}

function bltSetDay(yy,mm) //主要的写程序**********
{
bltWriteHead(yy,mm);
for (var i = 0; i < 37; i++)
{
bltWDay[i]=""
}; //将显示框的内容全部清空
var day1 = 1,firstday = new Date(yy,mm-1,1).getDay(); //某月第一天的星期几
for( var i = firstday; day1 < GetMonthCount(yy,mm)+1; i++)
{
bltWDay[i]=day1;
day1++;
}
for( var i = 0; i < 37; i++)
{ var da = eval("document.all.bltDay"+i) //书写新的一个月的日期星期排列
if (bltWDay[i]!="")
{
da.innerHTML = "<b>" + bltWDay[i] + "</b>";
da.style.backgroundColor = (yy == new Date().getFullYear() &&
// mm == new Date().getMonth()+1 && bltWDay[i] == new Date().getDate()) ? "#FFD700" : "#ADD8E6";
mm == new Date().getMonth()+1 && bltWDay[i] == new Date().getDate()) ? "#ADD8E6" : "#ADD8E6";
da.style.cursor="hand"
}
else
{
da.innerHTML="";
da.style.backgroundColor="";
da.style.cursor="default";
}
}
}
function bltSetDay1(yy,mm,hh,ms) //主要的写程序**********
{
bltWriteHead1(yy,mm,hh,ms);
for (var i = 0; i < 37; i++)
{
bltWDay[i]=""
}; //将显示框的内容全部清空
var day1 = 1,firstday = new Date(yy,mm-1,1).getDay(); //某月第一天的星期几
for( var i = firstday; day1 < GetMonthCount(yy,mm)+1; i++)
{
bltWDay[i]=day1;
day1++;
}
for( var i = 0; i < 37; i++)
{ var da = eval("document.all.bltDay"+i) //书写新的一个月的日期星期排列
if (bltWDay[i]!="")
{
da.innerHTML = "<b>" + bltWDay[i] + "</b>";
da.style.backgroundColor = (yy == new Date().getFullYear() &&
// mm == new Date().getMonth()+1 && bltWDay[i] == new Date().getDate()) ? "#FFD700" : "#ADD8E6";
mm == new Date().getMonth()+1 && bltWDay[i] == new Date().getDate()) ? "#ADD8E6" : "#ADD8E6";
da.style.cursor="hand"
}
else
{
da.innerHTML="";
da.style.backgroundColor="";
da.style.cursor="default";
}
}
}

function setDayTime()
{
var f = window.document.forms[ 0 ];
//注:在这里你可以输出改成你想要的格式
// alert(m_yy+"-"+m_mm+"-"+m_dd);
if( m_yy != null && m_mm != null && m_dd != null )
{

if( f.m_hour.value == '-' || f.m_min.value == '-' )//如果没选时间
outObject.value= m_yy + "-" + m_mm + "-" + m_dd;
else
outObject.value= m_yy + "-" + m_mm + "-" + m_dd + " " + f.m_hour.value + ":" + f.m_min.value + ":00";
}
closeLayer();
}
function bltDayClick( n, obj ) //点击显示框选取日期,主输入函数*************
{
var yy = bltTheYear;
var mm = bltTheMonth;
m_yy = yy;
if (mm < 10)
{
m_mm = "0" + mm;
}
else
{
m_mm = "" + mm;
}
if (outObject)
{
if (!n)
{
outObject.value="";
return;
}
if ( n < 10 )
{
m_dd = "0" + n;
}
else
{
m_dd = "" + n;
}
if( old_dd != null )
old_dd.style.backgroundColor = "#ADD8E6";
old_dd = obj;
obj.style.backgroundColor = "#FFD700";
}
else
{
closeLayer();
alert("输出有误!");
}
}

你可能感兴趣的:(JavaScript,jsp,F#,Microsoft,J#)