JS文件(保存为calendar.js):
var SelectDateObj;
function getobjectx(e){
var l=e.offsetLeft;
while(e=e.offsetParent){
l+=e.offsetLeft;
}
return l;
}
function getobjecty(e){
var t=e.offsetTop;
while(e=e.offsetParent){
t+=e.offsetTop;
}
return t;
}
function hidedate()
{
if(document.all.SelectDateList.style.display=='block')
document.all.SelectDateList.style.display='none';
}
function showdate(txtid)
{
SelectDateObj=eval("document.all."+txtid);
if(document.all.SelectDateList.style.display=='block')
document.all.SelectDateList.style.display='none';
else
{
TableFunction().JumpToRun("start");
//posX = event.clientX ;
//posY = event.clientY ;
var x,y;
x=getobjectx(SelectDateObj) ;
y=getobjecty(SelectDateObj) ;
document.all.SelectDateList.style.left = x+SelectDateObj.offsetWidth;
document.all.SelectDateList.style.top = y+SelectDateObj.offsetHeight;
document.all.SelectDateList.style.display='block';
}
}
function TableFunction()
{
this.GetDateStr=function(y,m)
{
this.DayArray=[];
for(var i=0;i<42;i++)this.DayArray[i]=" ";
for(var i=0;i return this.DayArray;
}
this.GetTableStr=function(y,m)
{
this.DateArray=["日","一","二","三","四","五","六"];
this.DStr="";
return this.DStr;
}
this.WriteSelect=function(obj,values,action,getobj)
{
if(values=="")return;
if(getobj)
{
obj.innerHTML=values+(action=="y"?" 年":" 月");
this.RewriteTableStr(YearTD.innerText.split(" ")[0],MonthTD.innerText.split(" ")[0]);
return false;
}
var StrArray=[];
if(action=="y")
{
for(var i=0;i<15;i++)
{
var year=values-7+i;
StrArray[i]="\n";
}
obj.innerHTML="";
select1.focus();
}
if(action=="m")
{
for(var i=1;i<13;i++)
StrArray[i]="\n";
obj.innerHTML="";
select2.focus();
}
}
this.RewriteTableStr=function(y,m)
{
var TArray=this.GetDateStr(y,m);
var len=TArray.length;
for(var i=0;i {
TD[i].innerHTML=TArray[i]+" ";
TD[i].className="TdOut";
TD[i].cs="TdOut";
if(new Date().getYear()==y&&new Date().getMonth()+1==m&&new Date().getDate()==TArray[i])
{
TD[i].className="TdOver";
TD[i].cs="TdOver";
}
}
}
this.JumpToRun=function(action)
{
var YearNO=YearTD.innerText.split(' ')[0];
var MonthNO=MonthTD.innerText.split(' ')[0];
if(action=="b")
{
if(MonthNO=="1")
{
MonthNO=13;
YearNO=YearNO-1;
}
MonthTD.innerText=MonthNO-1+" 月";
YearTD.innerText=YearNO+" 年";
this.RewriteTableStr(YearNO,MonthNO-1);
}
if(action=="n")
{
if(MonthNO=="12")
{
MonthNO=0;
YearNO=YearNO-(-1);
}
YearTD.innerText=YearNO+" 年";
MonthTD.innerText=MonthNO-(-1)+" 月";
this.RewriteTableStr(YearNO,MonthNO-(-1));
}
if(action=="start")
{
MonthNO=new Date().getMonth();
YearNO=new Date().getYear();
YearTD.innerText=YearNO+" 年";
MonthTD.innerText=MonthNO-(-1)+" 月";
this.RewriteTableStr(YearNO,MonthNO-(-1));
}
}
this.AlertDay=function()
{
if(event.srcElement.innerText!=" ")
SelectDateObj.innerText=YearTD.innerText.split(' ')[0]+"-"+MonthTD.innerText.split(' ')[0]+"-"+event.srcElement.innerText;
document.all.SelectDateList.style.display="none";
}
return this;
}
function selectfunction(timename,timevalue)
{
var timobj = eval("document.all."+timename)
with(timobj)
{
length = 24;
for(var i=0;i < 24;i++)
{
options[i].value=i;
options[i].text=i;
if (i == timevalue)
{
timobj.selectedIndex=timevalue;
}
}
}
}
document.write(TableFunction().GetTableStr(new Date().getYear(),new Date().getMonth()+1));
CSS文件(保存为calendar.css)
.body,td{
font-family:"Arial";
font-size:9pt;
color:#000000;
}
.TrOut{
background:#dddddd;
height:26;
border:1 solid #999999;
border-top-color:#f4f4f4;
border-left-color:#f4f4f4;
}
.TdOver{
background:#eeeeee;
height:20;
border:1 solid #ffffff;
border-top-color:#9c9c9c;
border-left-color:#9c9c9c;
color:red;
}
.TdOut{
background:#eeeeee;
height:20;
border:1 solid #9c9c9c;
border-top-color:#ffffff;
border-left-color:#ffffff;
}
.input2
{
BORDER: #838383 1px solid;
BACKGROUND-COLOR: #dff0EE;
font-weight: normal;
line-height: 120%
}
使用例子(TEMP.htm):
var SelectDateObj;
function getobjectx(e){
var l=e.offsetLeft;
while(e=e.offsetParent){
l+=e.offsetLeft;
}
return l;
}
function getobjecty(e){
var t=e.offsetTop;
while(e=e.offsetParent){
t+=e.offsetTop;
}
return t;
}
function hidedate()
{
if(document.all.SelectDateList.style.display=='block')
document.all.SelectDateList.style.display='none';
}
function showdate(txtid)
{
SelectDateObj=eval("document.all."+txtid);
if(document.all.SelectDateList.style.display=='block')
document.all.SelectDateList.style.display='none';
else
{
TableFunction().JumpToRun("start");
//posX = event.clientX ;
//posY = event.clientY ;
var x,y;
x=getobjectx(SelectDateObj) ;
y=getobjecty(SelectDateObj) ;
document.all.SelectDateList.style.left = x+SelectDateObj.offsetWidth;
document.all.SelectDateList.style.top = y+SelectDateObj.offsetHeight;
document.all.SelectDateList.style.display='block';
}
}
function TableFunction()
{
this.GetDateStr=function(y,m)
{
this.DayArray=[];
for(var i=0;i<42;i++)this.DayArray[i]=" ";
for(var i=0;i
}
this.GetTableStr=function(y,m)
{
this.DateArray=["日","一","二","三","四","五","六"];
this.DStr="";
return this.DStr;
}
this.WriteSelect=function(obj,values,action,getobj)
{
if(values=="")return;
if(getobj)
{
obj.innerHTML=values+(action=="y"?" 年":" 月");
this.RewriteTableStr(YearTD.innerText.split(" ")[0],MonthTD.innerText.split(" ")[0]);
return false;
}
var StrArray=[];
if(action=="y")
{
for(var i=0;i<15;i++)
{
var year=values-7+i;
StrArray[i]="\n";
}
obj.innerHTML="";
select1.focus();
}
if(action=="m")
{
for(var i=1;i<13;i++)
StrArray[i]="\n";
obj.innerHTML="";
select2.focus();
}
}
this.RewriteTableStr=function(y,m)
{
var TArray=this.GetDateStr(y,m);
var len=TArray.length;
for(var i=0;i
TD[i].innerHTML=TArray[i]+" ";
TD[i].className="TdOut";
TD[i].cs="TdOut";
if(new Date().getYear()==y&&new Date().getMonth()+1==m&&new Date().getDate()==TArray[i])
{
TD[i].className="TdOver";
TD[i].cs="TdOver";
}
}
}
this.JumpToRun=function(action)
{
var YearNO=YearTD.innerText.split(' ')[0];
var MonthNO=MonthTD.innerText.split(' ')[0];
if(action=="b")
{
if(MonthNO=="1")
{
MonthNO=13;
YearNO=YearNO-1;
}
MonthTD.innerText=MonthNO-1+" 月";
YearTD.innerText=YearNO+" 年";
this.RewriteTableStr(YearNO,MonthNO-1);
}
if(action=="n")
{
if(MonthNO=="12")
{
MonthNO=0;
YearNO=YearNO-(-1);
}
YearTD.innerText=YearNO+" 年";
MonthTD.innerText=MonthNO-(-1)+" 月";
this.RewriteTableStr(YearNO,MonthNO-(-1));
}
if(action=="start")
{
MonthNO=new Date().getMonth();
YearNO=new Date().getYear();
YearTD.innerText=YearNO+" 年";
MonthTD.innerText=MonthNO-(-1)+" 月";
this.RewriteTableStr(YearNO,MonthNO-(-1));
}
}
this.AlertDay=function()
{
if(event.srcElement.innerText!=" ")
SelectDateObj.innerText=YearTD.innerText.split(' ')[0]+"-"+MonthTD.innerText.split(' ')[0]+"-"+event.srcElement.innerText;
document.all.SelectDateList.style.display="none";
}
return this;
}
function selectfunction(timename,timevalue)
{
var timobj = eval("document.all."+timename)
with(timobj)
{
length = 24;
for(var i=0;i < 24;i++)
{
options[i].value=i;
options[i].text=i;
if (i == timevalue)
{
timobj.selectedIndex=timevalue;
}
}
}
}
document.write(TableFunction().GetTableStr(new Date().getYear(),new Date().getMonth()+1));
CSS文件(保存为calendar.css)
.body,td{
font-family:"Arial";
font-size:9pt;
color:#000000;
}
.TrOut{
background:#dddddd;
height:26;
border:1 solid #999999;
border-top-color:#f4f4f4;
border-left-color:#f4f4f4;
}
.TdOver{
background:#eeeeee;
height:20;
border:1 solid #ffffff;
border-top-color:#9c9c9c;
border-left-color:#9c9c9c;
color:red;
}
.TdOut{
background:#eeeeee;
height:20;
border:1 solid #9c9c9c;
border-top-color:#ffffff;
border-left-color:#ffffff;
}
.input2
{
BORDER: #838383 1px solid;
BACKGROUND-COLOR: #dff0EE;
font-weight: normal;
line-height: 120%
}
使用例子(TEMP.htm):
人生车站————记blo
今天收到Lava-Lav


August 21, 2006 17:24 | by 





