📄 datedialog.asp
字号:
<%
Dim ShowNow,I
ShowNow=CBool(Request.QueryString("ShowNow"))
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>选择日期</title>
</head>
<style type="text/css">
<!--
Body{
cursor: default;
}
.IntialStyle{
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #000000;
border-right-color: #FFFFFF;
border-bottom-color: #FFFFFF;
border-left-color: #000000;
}
.SelectStyle{
}
.DateMouseOver {
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #FFFFFF;
border-right-color: #000000;
border-bottom-color: #000000;
border-left-color: #FFFFFF;
}
.DateStyle {
cursor: default;
border: 1px solid buttonface;
}
-->
</style>
<link href="../inc/ModeWindow.css" rel="stylesheet">
<body>
<div align="center">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr align="center">
<td height="30" colspan="11" nowrap><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" align="right">
<select style="width:70;" onChange="ChangeDateNum();" name="YearList">
<% For i=1900 TO 2010
IF Year(Now())=I THEN
Response.Write("<option value="""&i&""" selected>"&i&"年</option>")
ELSE
Response.Write("<option value="""&i&""">"&i&"年</option>")
END IF
Next
%>
</select> <select style="width:50;" onChange="ChangeDateNum();" name="MonthList">
<%FOR i=1 to 12
IF i<10 THEN
IF Month(Now())=i THEN
Response.Write("<option value=""0"&i&""" selected>"&i&"月</option>")
Else
Response.Write("<option value=""0"&i&""">"&i&"月</option>")
END IF
ELSE
IF Month(Now())=i THEN
Response.Write("<option value="""&i&""" selected>"&i&"月</option>")
Else
Response.Write("<option value="""&i&""">"&i&"月</option>")
END IF
END IF
NEXT
%>
</select>
</td>
<td width="50%" align="center">
<table width="60%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td align="center" bordercolor="buttonface" onMouseOver="this.className='DateMouseOver';" onMouseOut="this.className='';" onMouseDown="this.className='IntialStyle';" onClick="TimeClick();">插入日期
</td>
</tr>
</table> </td>
</tr>
</table> </td>
</tr>
<tr>
<td height="25" align="center" class="DateStyle">1</td>
<td height="25" align="center" class="DateStyle">2</td>
<td height="25" align="center" class="DateStyle">3</td>
<td height="25" align="center" class="DateStyle">4</td>
<td height="25" align="center" class="DateStyle">5</td>
<td height="25" align="center" class="DateStyle">6</td>
<td height="25" align="center" class="DateStyle">7</td>
<td height="25" align="center" class="DateStyle">8</td>
<td height="25" align="center" class="DateStyle">9</td>
<td height="25" align="center" class="DateStyle">10</td>
<td height="25" align="center" class="DateStyle">11</td>
</tr>
<tr>
<td height="25" align="center" class="DateStyle">12</td>
<td height="25" align="center" class="DateStyle">13</td>
<td height="25" align="center" class="DateStyle">14</td>
<td height="25" align="center" class="DateStyle">15</td>
<td height="25" align="center" class="DateStyle">16</td>
<td height="25" align="center" class="DateStyle">17</td>
<td height="25" align="center" class="DateStyle">18</td>
<td height="25" align="center" class="DateStyle">19</td>
<td height="25" align="center" class="DateStyle">20</td>
<td height="25" align="center" class="DateStyle">21</td>
<td height="25" align="center" class="DateStyle">22</td>
</tr>
<tr>
<td height="25" align="center" class="DateStyle">23</td>
<td height="25" align="center" class="DateStyle">24</td>
<td height="25" align="center" class="DateStyle">25</td>
<td height="25" align="center" class="DateStyle">26</td>
<td height="25" align="center" class="DateStyle">27</td>
<td height="25" align="center" class="DateStyle">28</td>
<td height="25" id="Date29" align="center" class="DateStyle">29</td>
<td height="25" id="Date30" align="center" class="DateStyle">30</td>
<td height="25" id="Date31" align="center" class="DateStyle">31</td>
<td height="25" align="center"> </td>
<td height="25" align="center"> </td>
</tr>
</table>
</div>
</body>
</html>
<script language="JavaScript">
var bInitialized = false;
var AlreadySelectDate='';
var TimeStr;
window.setInterval('SetTimeInput();',1000);
function document.onreadystatechange()
{
if (document.readyState!="complete") return;
if (bInitialized) return;
bInitialized = true;
var i,Curr;
for (i=0; i<document.body.all.length;i++)
{
Curr=document.body.all[i];
if (Curr.className == "DateStyle") InitBtn(Curr);
}
var NowDate,YearStr,MonthStr,DateStr;
NowDate=new Date();
YearStr=NowDate.getYear();
MonthStr=NowDate.getMonth()+1;
DateStr=NowDate.getDate();
SelectDate(DateStr);
AlreadySelectDate=DateStr;
SetTimeInput();
ChangeDateNum();
}
function SetTimeInput()
{
var NowDate=new Date();
var MinuteStr= new String(NowDate.getMinutes());
if (MinuteStr.length==1) MinuteStr='0'+MinuteStr;
var SecondStr=new String(NowDate.getSeconds());
if (SecondStr.length==1) SecondStr='0'+SecondStr;
TimeStr=NowDate.getHours()+':'+MinuteStr+':'+SecondStr;
}
function InitBtn(btn)
{
btn.onmouseover = BtnMouseOver;
btn.onmouseout = BtnMouseOut;
btn.onmousedown = BtnMouseDown;
btn.onmouseup = BtnMouseOut;
btn.onclick=DateClick;
btn.ondblclick=DateDblClick;
btn.disabled=false;
return true;
}
function BtnMouseOver()
{
var image = event.srcElement;
image.className = "DateMouseOver";
event.cancelBubble = true;
}
function BtnMouseOut()
{
var image = event.srcElement;
image.className = "DateStyle";
event.cancelBubble = true;
}
function BtnMouseDown()
{
var image = event.srcElement;
image.className = "IntialStyle";
event.cancelBubble = true;
event.returnValue=false;
return false;
}
function SelectDate(Val)
{
for(var i=0;i<document.all.length;i++)
{
if (document.all(i).innerText==Val)
{
//document.all(i).className='IntialStyle';
document.all(i).bgColor='highlight';
document.all(i).style.color='white';
}
}
}
function DateClick()
{
AlreadySelectDate=event.srcElement.innerText;
for (var i=0;i<document.all.length;i++)
{
document.all(i).bgColor='';
document.all(i).style.color='Black';
}
event.srcElement.bgColor='highlight';
event.srcElement.style.color='white';
}
function DateDblClick()
{
var TempDateStr='';
TempDateStr=event.srcElement.innerText;
if (TempDateStr.length==1) TempDateStr='0'+TempDateStr;
window.returnValue=document.all.YearList.value+'-'+document.all.MonthList.value+'-'+TempDateStr;
window.close();
}
function TimeClick()
{
var TempDateStr='';
TempDateStr=AlreadySelectDate;
if (TempDateStr.length==1) TempDateStr='0'+TempDateStr;
<%IF ShowNow=true THEN%>
window.returnValue=document.all.YearList.value+'-'+document.all.MonthList.value+'-'+AlreadySelectDate+' '+TimeStr;
<%ELSE%>
window.returnValue=document.all.YearList.value+'-'+document.all.MonthList.value+'-'+AlreadySelectDate;
<%END IF%>
window.close();
}
window.onunload=CheckReturnValue;
function CheckReturnValue()
{
if (typeof(window.returnValue)!='string') window.returnValue='';
}
function ChangeDateNum()
{
var YearStr=document.all.YearList.value;
var MonthStr=document.all.MonthList.value;
var DateNumber=GetDayNum(YearStr,MonthStr);
switch (DateNumber)
{
case 31:
document.all.Date29.style.display='';
document.all.Date30.style.display='';
document.all.Date31.style.display='';
break;
case 30:
document.all.Date29.style.display='';
document.all.Date30.style.display='';
document.all.Date31.style.display='none';
break;
case 29:
document.all.Date29.style.display='';
document.all.Date30.style.display='none';
document.all.Date31.style.display='none';
break;
case 28:
document.all.Date29.style.display='none';
document.all.Date30.style.display='none';
document.all.Date31.style.display='none';
break;
default :
document.all.Date29.style.display='none';
document.all.Date30.style.display='none';
document.all.Date31.style.display='none';
}
}
function GetDayNum(YearVar, MonthVar)
{
var Temp,LeapYear,i,BigMonth;
var BigMonthArray=new Array('01','03','05','07','08','10','12');
YearVar=parseInt(YearVar);
//MonthVar=parseInt(MonthVar);
Temp=parseInt(YearVar/4);
if (YearVar==Temp*4) LeapYear=true;
else LeapYear = false
for(i=0;i<BigMonthArray.length;i++)
{
if (MonthVar==BigMonthArray[i])
{
BigMonth=true;
break;
}
else BigMonth=false;
}
if (BigMonth==true) return 31;
else
{
if (MonthVar==2)
{
if (LeapYear==true) return 29;
else return 28;
}
else return 30;
}
}
</script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -