书签 分享 收藏 举报 版权申诉 / 28

类型js实现日期下拉框.docx

  • 文档编号:30489355
  • 上传时间:2023-08-15
  • 格式:DOCX
  • 页数:28
  • 大小:23.93KB
");

window.cele_date.innerHTML="";

temp_str="";

temp_str+="

#000099;background-color:

#BFBFBF;cursor:

hand;border:

1;\">-";

temp_str+=""

temp_str+="

9pt;border:

1px#666666outset;background-color:

#F4F8FB\">"

for(i=1900;i<=2020;i++)

{

temp_str+=""+i.toString()+"";

}

temp_str+="-";

temp_str+=""

temp_str+="

9pt;border:

1px#666666outset;background-color:

#F4F8FB\">"

for(i=1;i<=12;i++)

{

temp_str+=""+i.toString()+"";

}

temp_str+="-";

temp_str+=""

temp_str+=">\"onclick=\"change_date(1,1)\"onmouseover=\"getlayerfocus()\"style=\"color:

#000099;background-color:

#BFBFBF;cursor:

hand;border:

1;\">";

temp_str+=""

temp_str+="日";temp_str+="一";temp_str+="二";temp_str+="三"

temp_str+="四";temp_str+="五";temp_str+="六";

for(i=1;i<=6;i++)

{

temp_str+="";

for(j=1;j<=7;j++){

temp_str+="

hand\"style=\"COLOR:

#000000\"language=\"javascript\"onmouseover=\"overcolor(this)\"onmouseout=\"outcolor(this)\"onclick=\"td_click(this)\">?

"

}

temp_str+=""

}

temp_str+="";

window.cele_date.innerHTML=temp_str;

}

functionset_cele_date(year,month)

{

vari,j,p,k

varnd=newDate(year,month-1,1);

event.cancelBubble=true;

cele_date_year.value=year;

cele_date_month.value=month;

k=nd.getDay()-1

vartemp;

for(i=1;i<=6;i++)

for(j=1;j<=7;j++)

{

eval("c"+i+"_"+j+".innerHTML=\"\"");

eval("c"+i+"_"+j+".bgColor=\"#DDDDDD\"");

eval("c"+i+"_"+j+".style.cursor=\"hand\"");

}

while(month-1==nd.getMonth())

{j=(nd.getDay()+1);

p=parseInt((nd.getDate()+k)/7)+1;

eval("c"+p+"_"+j+".innerHTML="+"\""+nd.getDate()+"\"");

if((nd.getDate()==today.getDate())&&(cele_date_month.value==today.getMonth()+1)&&(cele_date_year.value==today.getYear())){

eval("c"+p+"_"+j+".bgColor=\"#EFFB64\"");

}

if(nd>date_end||nd

{

eval("c"+p+"_"+j+".bgColor=\"#FF9999\"");

eval("c"+p+"_"+j+".style.cursor=\"text\"");

}

nd=newDate(nd.valueOf()+86400000)

}

}

//s_object:

点击的对象;d_start-d_end有效的时间区段;需要存放值的控件;

functionshow_cele_date(eP,d_start,d_end,t_object)

{

window.cele_date.style.display="";

window.cele_date.style.zIndex=99

vars,cur_d

vareT=eP.offsetTop;

vareH=eP.offsetHeight+eT;

vardH=window.cele_date.style.pixelHeight;

varsT=document.body.scrollTop;

varsL=document.body.scrollLeft;

event.cancelBubble=true;

window.cele_date.style.posLeft=event.clientX-event.offsetX+sL-5;

window.cele_date.style.posTop=event.clientY-event.offsetY+eH+sT-5;

if(window.cele_date.style.posLeft+window.cele_date.clientWidth>document.body.clientWidth)window.cele_date.style.posLeft+=eP.offsetWidth-window.cele_date.clientWidth;

if(d_start!

=""){

if(d_start=="today"){

date_start=newDate(today.getYear(),today.getMonth(),today.getDate());

}else{

s=d_start.split(separator);

date_start=newDate(s[0],s[1]-1,s[2]);

}

}else{

date_start=newDate(1900,1,1);

}

if(d_end!

=""){

s=d_end.split(separator);

date_end=newDate(s[0],s[1]-1,s[2]);

}else{

date_end=newDate(3000,1,1);

}

g_object=t_object

cur_d=newDate()

set_cele_date(cur_d.getYear(),cur_d.getMonth()+1);

window.cele_date.style.display="block";

window.cele_date.focus();

}

functiontd_click(t_object)

{

vart_d

if(parseInt(t_object.innerHTML,10)>=1&&parseInt(t_object.innerHTML,10)<=31)

{t_d=newDate(cele_date_year.value,cele_date_month.value-1,t_object.innerHTML)

if(t_d<=date_end&&t_d>=date_start)

{

varyear=cele_date_year.value;

varmonth=cele_date_month.value;

varday=t_object.innerHTML;

if(parseInt(month)<10)month="0"+month;

if(parseInt(day)<10)day="0"+day;

g_object.value=year+separator+month+separator+day;

window.cele_date.style.display="none";};

}

}

functionh_cele_date()

{

window.cele_date.style.display="none";

}

functionovercolor(obj)

{

if(obj.style.cursor=="hand")obj.style.color="#FFFFFF";

inover=true;

window.cele_date.focus();

}

functionoutcolor(obj)

{

obj.style.color="#000000";

inover=false;

}

functiongetNow(o){

varStamp=newDate();

varyear=Stamp.getYear();

varmonth=Stamp.getMonth()+1;

varday=Stamp.getDate();

if(month<10){

month="0"+month;

}

if(day<10){

day="0"+day;

}

o.value=year+separator+month+separator+day;

}

functionhilayer()

{

if(inover==false)

{

varlay=document.all.cele_date;

lay.style.display="none";

}

}

functiongetlayerfocus()

{

inover=true;

}

functionlostlayerfocus()

{

inover=false;

}

init();

//日历结束

///区域表单

cityareaname=newArray(35);

cityareacode=newArray(35);

functionfirst(preP,preC,formname,selectP,selectC)

{

a=0;

if(selectP=='01')

{a=1;tempoption=newOption('北京','北京',false,true);}

else

{tempoption=newOption('北京','北京');}

eval('document.'+formname+'.'+preP+'.options[1]=tempoption;');

cityareacode[0]=newArray('0101','0102','0103','0104','0105','0106','0107','0108');

cityareaname[0]=newArray('东城区','西城区','崇文区','宣武区','朝阳区','海淀区','丰台区','石景山');

if(selectP=='02')

{a=2;tempoption=newOption('深圳','深圳',false,true);}

else

{tempoption=newOption('深圳','深圳');}

eval('document.'+formname+'.'+preP+'.options[2]=tempoption;');

cityareacode[1]=newArray('0201','0202','0203','0204','0205','0206');

cityareaname[1]=newArray('罗湖','福田','南山','盐田','宝安','龙岗');

if(selectP=='03')

{a=3;tempoption=newOption('上海','上海',false,true);}

else

{tempoption=newOption('上海','上海');}

eval('document.'+formname+'.'+preP+'.options[3]=tempoption;');

cityareacode[2]=newArray('0301','0302','0303','0304','0305','0306','0307','0308','0309','0310','0311','0312','0313','0314','0315','0316','0317','0318','0319','0320');

cityareaname[2]=newArray('宝山','金山','南市','长宁','静安','青浦','崇明','卢湾','松江','奉贤','浦东','杨浦','虹口','普陀','闸北','黄浦','闵行','徐汇','嘉定','南汇');

if(selectP=='04')

{a=4;tempoption=newOption('重庆','重庆',false,true);}

else

{tempoption=newOption('重庆','重庆');}

eval('document.'+formname+'.'+preP+'.options[4]=tempoption;');

cityareacode[3]=newArray('0401','0402','0403','0404','0405','0406');

cityareaname[3]=newArray('渝中','江北','沙坪坝','南岸','九龙坡','大渡口');

if(selectP=='05')

{a=5;tempoption=newOption('天津','天津',false,true);}

else

{tempoption=newOption('天津','天津');}

eval('document.'+formname+'.'+preP+'.options[5]=tempoption;');

cityareacode[4]=newArray('0501','0502','0503','0504','0505','0506','0507','0508','0509','0510','0511','0512','0513','0514','0515');

cityareaname[4]=newArray('和平','河北','河西','河东','南开','红桥','塘沽','汉沽','大港','东丽','西青','津南','北辰','武清','滨海');

if(selectP=='06')

{a=6;tempoption=newOption('广东','广东',false,true);}

else

{tempoption=newOption('广东','广东');}

配套讲稿:

如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

特殊限制:

部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

关 键  词:
js 实现 日期 下拉
提示  冰豆网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
关于本文
本文标题:js实现日期下拉框.docx
链接地址:https://www.bdocx.com/doc/30489355.html
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2008-2022 冰点文档网站版权所有

经营许可证编号:鄂ICP备2022015515号-1

收起
展开