一個純指令碼寫的日期控制項

來源:互聯網
上載者:User
指令碼|控制項|指令碼|控制項 使用的是一個img作為按鈕,一個iframe載入日期頁面
<IMG id="ImgDate" style="LEFT: 137px; CURSOR: hand; POSITION: absolute; TOP: 1px" onclick="SetlstDate1Visible('TxtDate')" src=http://www.163design.net/a/y/"images/ImgBtn/frmMainDate.gif" width="21">

<IFRAME class="dtpMonth1" id="lstDate1" style="DISPLAY: none; Z-INDEX: 105; LEFT: 112px; WIDTH: 176px; POSITION: absolute; TOP: 152px; HEIGHT: 160px"
tabIndex="-1" name="lstDate1" src="frmDate.aspx" frameBorder="0" scrolling="no">
</IFRAME>

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="frmDate.aspx.vb" Inherits="MOST_WEB.frmDate"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>dtpDate1</title>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
<meta content="Microsoft Visual Studio .NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<LINK href="Styles.css" type="text/css" rel="stylesheet">
<script language="javascript" src="comFuncs.js"></script>
<script language="JavaScript">
function RunNian(The_Year)//取得是否為潤年
{
if ((The_Year%400==0) || ((The_Year%4==0) && (The_Year%100!=0)))
return true;
else
return false;
}

function GetWeekday(The_Year,The_Month)
{

var Allday;
Allday = 0;
if (The_Year>2000)
{
for (i=2000 ;i<The_Year; i++) //計算從2000年開始到今年的天數
{
if (RunNian(i)){
Allday += 366;
}else{
Allday += 365;
}
}

for (i=2; i<=The_Month; i++)
{
switch (i)
{
case 2 : Allday += 31; break;
case 3 :
if (RunNian(The_Year)){
Allday += 29;
}else{
Allday += 28;
}
break;
case 4 : Allday += 31; break;
case 5 : Allday += 30; break;
case 6 : Allday += 31; break;
case 7 : Allday += 30; break;
case 8 : Allday += 31; break;
case 9 : Allday += 31; break;
case 10 : Allday += 30; break;
case 11 : Allday += 31; break;
case 12 : Allday += 30; break;
}
}
}
return (Allday+6)%7;
}

function chooseday(objName,The_Year,The_Month,The_Day)
{
var Firstday;
Firstday = GetWeekday(The_Year,The_Month);//取得星期幾
ShowCalender(objName,The_Year,The_Month,The_Day);
}

function showdate(objName,The_Year,The_Month,The_Day){//顯示日期,將所選的日期傳到textbox中顯示出來
var txtDate;
objName="TxtDate";
txtDate= objName;

var completely_date;
var cur_Month
var cur_Day
if (The_Month.toString().length==1){//給月前面加0
cur_Month="0"+The_Month
}else{
cur_Month=The_Month
}
if (The_Day.toString().length==1){//給日期前加0
cur_Day="0"+The_Day
}else{
cur_Day=The_Day
}
if (The_Day!=0)//調整日期的樣式
completely_date = The_Year + "/" + cur_Month + "/" + cur_Day;
else
completely_date = "No Choose";

parent.document.all(txtDate).innerText = completely_date;//顯示給textbox
}

function nextmonth(objName,The_Year,The_Month,The_Day)//選擇下個月
{
if (The_Month==12)
chooseday(objName,The_Year+1,1,The_Day);
else
chooseday(objName,The_Year,The_Month+1,The_Day);
}

function prevmonth(objName,The_Year,The_Month,The_Day)//選擇上一月
{
if (The_Month==1)
chooseday(objName,The_Year-1,12,The_Day);
else
chooseday(objName,The_Year,The_Month-1,The_Day);
}
function closeself(){
top.document.frames(1).document.frames(1).ObjLostFocus();
}



相關文章

Cloud Intelligence Leading the Digital Future

Alibaba Cloud ACtivate Online Conference, Nov. 20th & 21st, 2019 (UTC+08)

Register Now >

Starter Package

SSD Cloud server and data transfer for only $2.50 a month

Get Started >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。