选择日期控件

原创 2006年05月23日 17:35:00

//选择时间by zwb
function SelDateById(ControlId)
{
  ArgDate=document.getElementById(ControlId).value;
  ReturnValue=window.showModalDialog("../SelDate.htm",ArgDate,
  "dialogWidth:336px;dialogHeight:280px;Resizable:0;help=no;status:No;center:yes;" );
  if (ReturnValue!=undefined)
    {
      document.getElementById(ControlId).value=ReturnValue;
   return false;
 }
  else
    {
      return false;
 }
}

//SelDate.htm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 
<HEAD>
<title>选择日期</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
var toDay=new Date();
var toDayYear=toDay.getFullYear();
var toDayMonth=toDay.getMonth();
var toDayDate=toDay.getDate();
var selectedDate;
function FormOnLoad()
{
 var year;
 var month;
 var day
 var myDate=new Date();
 try{
  if (window.dialogArguments!=undefined && window.dialogArguments!="")
  {
   var ArgStr=window.dialogArguments;
   var DateArry=ArgStr.split(".");
   if(DateArry.length==3){
    DateArry=ArgStr.split("-");
    myDate=new Date(DateArry[0],DateArry[1]-1,DateArry[2]);
   }
  }
 }catch(e){}
 month=myDate.getMonth();
 document.frmDate.year.value=myDate.getFullYear();
 document.frmDate.month.selectedIndex=month;
 selectedDate=myDate.getDate();
 setDayTab(myDate.getFullYear(),month);
}
function setDayTab(year,month){
 var xxDate=new Date(year,month,1)
 var days=31;
 var d2
 var wd=xxDate.getDay();
 if(month<11){
  d2=new Date(year,month+1,1);
  days=(d2-xxDate)/(24*60*60*1000);
 }
 predays=31;
 if(month>0){
  d2=new Date(year,month-1,1);
  predays=(xxDate-d2)/(24*60*60*1000);
 }
 for(i=0;i<wd;i++){
  xx=predays-wd+i+1;
  document.all["DL1"+i].innerHTML=xx;
  document.all["DL1"+i].className="toDisDay";
 }
 var j;
 var x=1;
 for(j=1;j<=days;){
  for(;wd<7 && j<=days;wd++,j++){
   document.all["DL"+x+""+wd].innerHTML=j;
   if(year==toDayYear && month==toDayMonth && j==toDayDate){
    if(selectedDate==j){
     document.all["DL"+x+""+wd].className="toDaySelectedDay";
    }else{
     document.all["DL"+x+""+wd].className="toDay";
    }
   }else if(selectedDate==j){
    document.all["DL"+x+""+wd].className="toSeletedDay";
   }else{
    document.all["DL"+x+""+wd].className="generDay";
   }
   document.all["DL"+x+""+wd].style.cursor="hand";
   document.all["DL"+x+""+wd].dayValue=j;
   document.all["DL"+x+""+wd].title="双击选择"+year+"年"+document.frmDate.month[month].text+j+"日";
   document.all["DL"+x+""+wd].onclick=clickToSelected;
   document.all["DL"+x+""+wd].ondblclick=BtnOKOnClick;
  }
  if(j<=days){
   wd=0;
   x++;
  }
 }
 j=1;
 for(;x<7;x++){
  for(;wd<7;wd++,j++){
   document.all["DL"+x+""+wd].innerHTML=j;
   document.all["DL"+x+""+wd].className="toDisDay";
  }
  wd=0;
 }
}
function clickToSelected(){
 if(event.srcElement.dayValue!=null){
  selectedDate=event.srcElement.dayValue;
  setDayTab(document.frmDate.year.value,document.frmDate.month.selectedIndex);
 }
}
function onMonthchange(){
 setDayTab(document.frmDate.year.value,document.frmDate.month.selectedIndex);
}
function btnOk(){
 window.returnValue=document.frmDate.year.value+"-"+(document.frmDate.month.selectedIndex+1)+"-"+selectedDate;
 window.close();   
}
function BtnOKOnClick() 
{
 if(event.srcElement.dayValue!=null){
  window.returnValue=document.frmDate.year.value+"-"+(document.frmDate.month.selectedIndex+1)+"-"+event.srcElement.dayValue;
  window.close();   
 }
}
</script>
<style type="text/css">
<!--
TD {
 font-size: 9pt;
}
th {
 font-size: 9pt;
}
option {
 color: #006699;
 border: 1px solid #003366;
}
select {
 font-size: 9pt;
 border: 1px solid #990000;
}
.toHead {
 color: #FFFFFF;
 background-color: #003366;
}
.toSeletedDay {
 color: #FFFFFF;
 background-color: #003399;
}
.toDisDay {
 color: #999999;
}
.toDay {
 border: 1px solid #990000;
}
.toDaySelectedDay {
 border: 1px solid #990000;
 color: #FFFFFF;
 background-color: #003399;
}
-->
</style>
</HEAD>
<BODY bgcolor="#CCCCCC" leftMargin="0" topMargin="0" rightMargin="0" bottomMargin="0" marginwidth="0" marginheight="0" onload="FormOnLoad()">
<form name="frmDate" onSubmit="return false;">
  <div align="center">
    <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td align="center">
<table border="1" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC" bordercolorlight="#000000" bordercolordark="#ffffff" width=90%>
            <tr>
              <td><table border="0" cellpadding="4" cellspacing="1" width=100%>
                  <tr>
                    <th colspan="7"> <table border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td><input name="year" type="text" id="year" size="6" maxlength="4" onBlur="onMonthchange()">
                          </td>
                          <td align="right"> <select name="month" onchange="onMonthchange()">
                              <option value="1">一月</option>
                              <option value="2">二月</option>
                              <option value="3">三月</option>
                              <option value="4">四月</option>
                              <option value="5">五月</option>
                              <option value="6">六月</option>
                              <option value="7">七月</option>
                              <option value="8">八月</option>
                              <option value="9">九月</option>
                              <option value="10">十月</option>
                              <option value="11">十一月</option>
                              <option value="12">十二月</option>
                            </select> </td>
                        </tr>
                      </table></th>
                  </tr>
                  <tr>
                    <th class="toHead">日</th>
                    <th class="toHead">一</th>
                    <th class="toHead">二</th>
                    <th class="toHead">三</th>
                    <th class="toHead">四</th>
                    <th class="toHead">五</th>
                    <th class="toHead">六</th>
                  </tr>
                  <tr>
                    <td align="center" id="DL10">&nbsp;</td>
                    <td align="center" id="DL11">&nbsp;</td>
                    <td align="center" id="DL12">&nbsp;</td>
                    <td align="center" id="DL13">&nbsp;</td>
                    <td align="center" id="DL14">&nbsp;</td>
                    <td align="center" id="DL15">&nbsp;</td>
                    <td align="center" id="DL16">&nbsp;</td>
                  </tr>
                  <tr>
                    <td align="center" id="DL20">&nbsp;</td>
                    <td align="center" id="DL21">&nbsp;</td>
                    <td align="center" id="DL22">&nbsp;</td>
                    <td align="center" id="DL23">&nbsp;</td>
                    <td align="center" id="DL24">&nbsp;</td>
                    <td align="center" id="DL25">&nbsp;</td>
                    <td align="center" id="DL26">&nbsp;</td>
                  </tr>
                  <tr>
                    <td align="center" id="DL30">&nbsp;</td>
                    <td align="center" id="DL31">&nbsp;</td>
                    <td align="center" id="DL32">&nbsp;</td>
                    <td align="center" id="DL33">&nbsp;</td>
                    <td align="center" id="DL34">&nbsp;</td>
                    <td align="center" id="DL35">&nbsp;</td>
                    <td align="center" id="DL36">&nbsp;</td>
                  </tr>
                  <tr>
                    <td align="center" id="DL40">&nbsp;</td>
                    <td align="center" id="DL41">&nbsp;</td>
                    <td align="center" id="DL42">&nbsp;</td>
                    <td align="center" id="DL43">&nbsp;</td>
                    <td align="center" id="DL44">&nbsp;</td>
                    <td align="center" id="DL45">&nbsp;</td>
                    <td align="center" id="DL46">&nbsp;</td>
                  </tr>
                  <tr>
                    <td align="center" id="DL50">&nbsp;</td>
                    <td align="center" id="DL51">&nbsp;</td>
                    <td align="center" id="DL52">&nbsp;</td>
                    <td align="center" id="DL53">&nbsp;</td>
                    <td align="center" id="DL54">&nbsp;</td>
                    <td align="center" id="DL55">&nbsp;</td>
                    <td align="center" id="DL56">&nbsp;</td>
                  </tr>
                  <tr>
                    <td align="center" id="DL60">&nbsp;</td>
                    <td align="center" id="DL61">&nbsp;</td>
                    <td align="center" id="DL62">&nbsp;</td>
                    <td align="center" id="DL63">&nbsp;</td>
                    <td align="center" id="DL64">&nbsp;</td>
                    <td align="center" id="DL65">&nbsp;</td>
                    <td align="center" id="DL66">&nbsp;</td>
                  </tr>
                </table></td>
            </tr>
          </table>
          <table border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="80">
<input name="按钮" type="button" value="确定" onclick="btnOk()">
              </td>
              <td><input type="button" value="取消" onclick="window.close();"></td>
            </tr>
          </table></td>
      </tr>
    </table>
  </div>
</form>
</BODY>
</HTML>

版权声明:本文为博主原创文章,未经博主允许不得转载。 举报

相关文章推荐

修改easyui日期控件只显示年月,并且只能选择年月

今天使用easyUI做前端时,有一个需求是只能选择年月,不要日。而easyUI自带的是没有这种选法的,故为实现需求进行如下改动,以下是源码: 更改easyui日期控件,使其只显示到年月 ...

Android自定义垂直滚动自动选择日期控件

项目中需要一个日期选择控件,该日期选择控件是垂直滚动,停止滚动时需要校正日期数字位置,自动选择离中心位置最近的数字。可能有其他的应用场景,分享给各位,可以修改或应用于你自己的项目。

我是如何成为一名python大咖的?

人生苦短,都说必须python,那么我分享下我是如何从小白成为Python资深开发者的吧。2014年我大学刚毕业..

带时间选择得JS日期控件

很多时候需要用到带时间选择的日期控件,在网上搜索了很多终于搜到了梅子(meizz)的一个,具体是什么时候的版本不清楚了,现在的3.0版本上是没有选择时间的。     兴奋之余,看到这个控件原来没有秒...
  • Orehs
  • Orehs
  • 2012-11-23 11:59
  • 1195

My97 datepicker 日期控件添加时间自动选择 年龄,生肖,星座

我这里使用Wabacus作为示例: onpicked:autoLoadAge"/> * 年龄:" br="true"> ...

Ext4 日期控件[Y-m]选择2月变3月解决方案

在Ext中,当日期控件是年月格式的时候会发生一种问题,就是选择2月的时候会变成3月. 在电脑时间当前日期在1到28号是正常的.29号到31号就会出现这类问题了. 原因是当你选择日期的时候,格式是Y...

EasyUi日期控件datebox设置,只显示年月,也只能选择年月

EasyUi日期控件datebox设置,只显示年月,也只能选择年月

选择输入日期控件源代码

using System; using System.Collections; using System.Collections.Specialized; using System.Compon...

一款可以限定选择区域的日期控件

这个开源控件可以兼容到SDK8版本,可以自定义显示的年月日,以及时间范围,如图     如果我们只想显示两个月的日期选择区间: final Calendar month = Calendar.get...
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)