首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

,ASP单击文本框出现日期控件?做一个日期的

2012-02-23 
在线等,急,ASP单击文本框出现日期控件?做一个日期的在线等,急,ASP单击文本框出现日期控件?做一个日期的[解

在线等,急,ASP单击文本框出现日期控件?做一个日期的
在线等,急,ASP单击文本框出现日期控件?做一个日期的

[解决办法]
/*firefox window.event*/
function __firefox(){
HTMLElement.prototype.__defineGetter__("runtimeStyle", __element_style);
window.constructor.prototype.__defineGetter__("event", __window_event);
Event.prototype.__defineGetter__("srcElement", __event_srcElement);
}
function __element_style(){
return this.style;
}
function __window_event(){
return __window_event_constructor();
}
function __event_srcElement(){
return this.target;
}
function __window_event_constructor(){
if(document.all){
return window.event;
}
var _caller = __window_event_constructor.caller;
while(_caller!=null){
var _argument = _caller.arguments[0];
if(_argument){
var _temp = _argument.constructor;
if(_temp.toString().indexOf("Event")!=-1){
return _argument;
}
}
_caller = _caller.caller;
}
return null;
}
if(window.addEventListener){
__firefox();
}
/*end firefox.event
----------------------------------------*/
//日历显示的对象
document.writeln("<style>#LTDiv{overflow:hidden;margin:0px;position:absolute;width:144px;display:none;border:1px solid #78B9D8;padding:1px;background-color:#fff;}\r\
#LTDiv ul,#LTDiv li{border:0px;margin:0px;padding:0px;font-size:12px;font-family:宋体;list-style:none}\r\
.LTYear li{float:left;line-height:22px;width:14px;text-align:center;cursor:pointer;}\r\
.LTYear{background-color:#FCFDFE;border-bottom:1px solid #fff;color:#00c;clear:both;height:22px;}\r\
.LTWeek li{float:left;width:20px;text-align:center;line-height:20px;color:#fff}\r\
.LTWeek{background-color:#78B9D8;height:20px;clear:both}\r\
.LTDay{border:0px;margin:0px;padding:0px;clear:both}\r\
.LTDay ul{clear:both}\r\
.LTDay li{float:left;width:20px;text-align:center;height:20px;line-height:20px;color:#04d}\r\
.LTDay .ifo2{color:#AAA}\r\
.LTDay .ifo1{cursor:pointer}\r\
.LTDay .ifo3{cursor:pointer;font-weight:bold;text-decoration:underline}\r\
.LTDay .ifo4{cursor:pointer;background-color:#DDEDF4;}\r\
</style>")
document.writeln("<div id='LTDiv'></div>")
//日历初始化
function WebCalendar(){
this.iYear = new Date().getFullYear();//年
this.iMonth = new Date().getMonth()+ 1;//月
this.iToday = new Date().getFullYear()+"-"+appendZero(new Date().getMonth()+1)+"-"+appendZero(new Date().getDate());//今天
this.iObj = null;
this.uObj = null;
}
var iCalendar = new WebCalendar()
//日历显示的对象内容
function DivCalendar(){
var iYear = iCalendar.iYear; 
var iMonth = iCalendar.iMonth-1; 
var iWeek = new Date(iYear, iMonth, 1).getDay();//星期
var iEndDay = new Date(iYear, iMonth +1, 0).getDate();//最后一天

var CalendarText="<div class='LTYear'><ul><li onclick='SetYear(-1)' title='向前翻 1 年'>&lt;&lt;</li><li onclick='SetMonth(-1)') title='向前翻 1 月'>&lt;</li><li style='width:50px;text-align:center'>"+iYear+"年</li><li style='width:30px;text-align:center'>"+appendZero(iMonth+1)+"月</li><li onclick='SetMonth(1)' title='向后翻 1 月'>&gt;</li><li onclick='SetYear(1)' title='向后翻 1 年'>&gt;&gt;</li></ul></div>";
CalendarText+="<div class='LTWeek'><ul><li style='color:#FFFF15'>日</li><li>一</li><li>二</li><li>三</li><li>四</li><li>五</li><li style='color:#FFFF15'>六</li></ul></div>";
CalendarText+="<div class='LTDay'><ul>";


for(n=1;n<=iWeek;n++){CalendarText+="<li>&nbsp;</li>"}
var istyle,iStrDay
//输入日历部分
for(i=1;i<=iEndDay;i++){
istyle=" class='ifo1' onclick=iCalendarVale('"+(iYear+"-"+appendZero(iMonth+1)+"-"+appendZero(i))+"') onmouseover=this.className='ifo4' onmouseout=this.className='ifo1'";
//判断日期是否已过
if ((iYear+"-"+appendZero(iMonth+1)+"-"+appendZero(i))<iCalendar.iToday){istyle=" class='ifo2'";}
//判断是否为当天日期
if ((iYear+"-"+appendZero(iMonth+1)+"-"+appendZero(i))==iCalendar.iToday){istyle=" class='ifo3' onclick=iCalendarVale('"+(iYear+"-"+appendZero(iMonth+1)+"-"+appendZero(i))+"') onmouseover=this.className='ifo4' onmouseout=this.className='ifo3'";}
CalendarText+="<li"+istyle+" title='"+(iYear+"-"+appendZero(iMonth+1)+"-"+appendZero(i))+"'>"+i+"</li>"
if ( new Date(iYear, iMonth, i).getDay()==6){CalendarText+="</ul><ul>"}//判断是否到周未
}
CalendarText+="</ul></div>";
document.getElementById("LTDiv").innerHTML = CalendarText;//载入日历到层中
}
//调用函数
function calendar(){
//获取对象
var e=window.event.srcElement,Obj;
if (arguments.length == 0 ){
Obj = e;
}else{
if(typeof(arguments[0])=='object'){
Obj=arguments[0];
}else{
Obj = document.getElementById(arguments[0]);
}
}

iCalendar.iObj=Obj;
iCalendar.uObj=e;
DivCalendar();//显示日历
var iDiv = document.getElementById("LTDiv");
iDiv.style.display = "block";
//取得对象位置给层定位
var t = e.offsetTop, h = e.clientHeight, l = e.offsetLeft,p = e.type;//控件的信息
while (e = e.offsetParent){t += e.offsetTop; l += e.offsetLeft;}

var cw = iDiv.clientWidth, ch = iDiv.clientHeight;
var dw = document.body.clientWidth, dl = document.body.scrollLeft, dh = document.body.clientHeight,dt = document.body.scrollTop;
if (document.body.clientHeight + dt - t - h >= ch) {
iDiv.style.top = ((p=="image")? t + h : t + h + 3)+'px';
}else {
iDiv.style.top = ((t - dt < ch) ? ((p=="image")? t + h : t + h + 3) : t - ch)+'px';
}
if (dw + dl - l >= cw){
iDiv.style.left = l+'px'; 
}else{ 
iDiv.style.left = ((dw >= cw) ? dw - cw + dl : dl)-4+'px';
}
iDiv.style.display = "block";
document.onclick=this.click_hCity;
}
//年设置
function SetYear(str){iCalendar.iYear=iCalendar.iYear+str;DivCalendar()}
//月设置
function SetMonth(str){
if(iCalendar.iMonth==1 && str<0){iCalendar.iYear=iCalendar.iYear-1;iCalendar.iMonth=13}
if(iCalendar.iMonth==12 && str>0){iCalendar.iYear=iCalendar.iYear+1;iCalendar.iMonth=0}
iCalendar.iMonth=iCalendar.iMonth+str;
DivCalendar()
}
function appendZero(n){return(("00"+ n).substr(("00"+ n).length-2));}//日期自动补零程序
this.iCalendarVale = function (Str){iCalendar.iObj.value=Str; hCity();}//输入日期
function hCity(){document.getElementById("LTDiv").style.display="none";}//隐藏层
this.click_hCity = function (e){if(iCalendar.uObj !=event.srcElement) hCity();}//任何点击隐藏层

热点排行