js日期控件 1
系统
1918 0
js代码
<
SCRIPT LANGUAGE
=
"
JavaScript
"
>
<!--
//
有效的时间范围
var
date_start,date_end,g_object
var
today
=
new
Date();
var
separator
=
"
-
"
;
var
inover
=
false
;
//
mode :时间变换的类型0-年 1-月 2-直接选择月
function
change_date(temp,mode)
...
{
var
t_month,t_year
if
(mode)
...
{
if
(mode
==
1
)
t_month
=
parseInt(cele_date_month.value,
10
)
+
parseInt(temp,
10
);
else
t_month
=
parseInt(temp)
if
(t_month
<
cele_date_month.options(
0
).text)
...
{
cele_date_month.value
=
cele_date_month.options(cele_date_month.length
-
1
).text;
change_date(parseInt(cele_date_year.value,
10
)
-
1
,
0
);
}
else
...
{
if
(t_month
>
cele_date_month.options(cele_date_month.length
-
1
).text)
...
{
cele_date_month.value
=
cele_date_month.options(
0
).text;
change_date(parseInt(cele_date_year.value,
10
)
+
1
,
0
);
}
else
...
{cele_date_month.value
=
t_month;
set_cele_date(cele_date_year.value,cele_date_month.value);
}
}
}
else
...
{
t_year
=
parseInt(temp,
10
);
if
(t_year
<
cele_date_year.options(
0
).text)
...
{
cele_date_year.value
=
cele_date_year.options(
0
).text;
set_cele_date(cele_date_year.value,
1
);
}
else
...
{
if
(parseInt(t_year,
10
)
>
parseInt(cele_date_year.options(cele_date_year.length
-
1
).text,
10
))
...
{
cele_date_year.value
=
cele_date_year.options(cele_date_year.length
-
1
).text;
set_cele_date(cele_date_year.value,
12
);
}
else
...
{cele_date_year.value
=
t_year;
set_cele_date(cele_date_year.value,cele_date_month.value);
}
}
}
/**/
/*
2002-02-01 MODIFY BY John
*/
window.cele_date.focus();
/**/
/*
MODIFY END
*/
}
//
初始化日历
function
init(d_start,d_end)
...
{
var
temp_str;
var
i
=
0
var
j
=
0
date_start
=
new
Date(
2000
,
7
,
1
)
date_end
=
new
Date(
2004
,
8
,
1
)
//
必须要有内容(奇怪)
/**/
/*
2002-02-01 MODIFY BY John
*/
document.writeln(
"
<div name="cele_date" id="cele_date" style="display:none" style="LEFT: 69px; POSITION: absolute; TOP: 159px;Z-INDEX:99" onClick="event.cancelBubble=true;" onBlur="hilayer()" onMouseout="lostlayerfocus()">? </div>
"
);
/**/
/*
MODIFY END
*/
window.cele_date.innerHTML
=
""
;
temp_str
=
"
<table border="2" bgcolor="#D66939" bordercolor="#000000"><tr align="center"><td colspan=7 bordercolor="#D66939" onmouseover="overcolor(this)">
"
;
temp_str
+=
"
<input type="Button" value="& lt;<" onclick="change_date(-1,1)" onmouseover="getlayerfocus()" style="color: #FFFFFF; background- color: #A52810; font-family:宋体;font-size:10px;text- align:center;border:2 solid #A52810; cursor: hand">
"
;
//
左面的箭头,#ffffff是<<显示的颜色,#A52810是背景按钮的颜色
/**/
/*
2002-02-01 MODIFY BY John
*/
/**/
/*
temp_str+="<input type="Button" value="<<" onclick="change_date(-1,1)" >?";//左面的箭头
*/
/**/
/**/
temp_str
+=
""
//
年
temp_str
+=
"
<select name="cele_date_year" id="cele_date_year" language="javascript" onchange="change_date(this.value,0)" onmouseover="getlayerfocus()" onblur="getlayerfocus()" style="font-size: 9pt; border: 0px #ffffff outset; background-color: #F4F8FB">
"
//
#F4F8FB设置年下拉选择框的颜色为白色
/**/
/*
2002-02-01 MODIFY BY John
*/
/**/
/*
temp_str+="<select name="cele_date_year" id="cele_date_year" language="javascript" onchange="change_date(this.value,0)">"
*/
/**/
/**/
for
(i
=
2001
;i
<=
2009
;i
++
)
...
{
temp_str
+=
"
<OPTION value="
"
+
i.toString()
+
"
">
"
+
i.toString()
+
"
</OPTION>
"
;
}
temp_str
+=
"
</select>
"
;
temp_str
+=
""
//
月
temp_str
+=
"
<select name="cele_date_month" id="cele_date_month" language="javascript" onchange="change_date(this.value,2)" onmouseover="getlayerfocus()" onblur="getlayerfocus()" style="font-size: 9pt; border: 0px #666666 outset; background-color: #F4F8FB">
"
//
#F4F8FB设置月下拉选择框的颜色为白色
/**/
/*
2002-02-01 MODIFY BY WING *
*/
/**/
/*
temp_str+="<select name="cele_date_month" id="cele_date_month" language="javascript" onchange="change_date(this.value,2)">"
*/
/**/
/**/
for
(i
=
1
;i
<=
12
;i
++
)
...
{
temp_str
+=
"
<OPTION value="
"
+
i.toString()
+
"
">
"
+
i.toString()
+
"
</OPTION>
"
;
}
temp_str
+=
"
</select>
"
;
temp_str
+=
""
//
右箭头
temp_str
+=
"
<input type="Button" value="& gt;>" onclick="change_date(1,1)" onmouseover="getlayerfocus()" style="color: #FFFFFF; background- color: #A52810; font-family:宋体;font-size:10px;text- align:center;border:2 solid #A52810; cursor: hand">
"
;
//
#FFFFFF设置月右移双箭头的颜色为白色,#A52810设置月右移双箭头的背景色
/**/
/*
2002-02-01 MODIFY BY WING **
*/
js日期控件 1
更多文章、技术交流、商务合作、联系博主
微信扫码或搜索:z360901061
微信扫一扫加我为好友
QQ号联系: 360901061
您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。
【本文对您有帮助就好】元