js日期控件 1

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" οnmοuseοver="overcolor(this)">";
     temp_str
+="<input type="Button" value="& lt;<" οnclick="change_date(-1,1)" οnmοuseοver="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="<<" οnclick="change_date(-1,1)" >?";//左面的箭头                                */
     
/**/
     
     temp_str
+=""//年 
     temp_str+="<select name="cele_date_year" id="cele_date_year" language="javascript" οnchange="change_date(this.value,0)" οnmοuseοver="getlayerfocus()" οnblur="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" οnchange="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" οnchange="change_date(this.value,2)" οnmοuseοver="getlayerfocus()" οnblur="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" οnchange="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;>" οnclick="change_date(1,1)" οnmοuseοver="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 ***/
     
/*temp_str+="<input type="Button" value=">>" οnclick="change_date(1,1)">";                                                    */
     
/**/


     
//151行 #000000设置最初显示的日期数字的颜色
     temp_str+="</td></tr><tr bordercolor="#D66939"><td οnmοuseοver="overcolor(this)">"
     temp_str
+="<font color=white>Su</font></td><td>";
  temp_str
+="<font color=white>Mo</td><td>"; temp_str+="<font color=white>Tu</td><td>"; temp_str+="<font color=white>We</td><td>"
     temp_str
+="<font color=white>Th</td><td>";temp_str+="<font color=white>Fr</td><td>"; temp_str+="<font color=white>Sa</td></tr>";
     
for (i=1 ;i<=6 ;i++)
     
{
     temp_str
+="<tr bordercolor="#A52810">";
        
for(j=1;j<=7;j++){
            temp_str
+="<td name="c"+i+"_"+j+""id="c"+i+"_"+j+"" style="CURSOR: hand" style="COLOR:#ffffff" language="javascript" οnmοuseοver="overcolor(this)" οnmοuseοut="outcolor(this)" οnclick="td_click(this)">?</td>"
            }

     temp_str
+="</tr>"        
     }

     temp_str
+="</td></tr></table>";
     window.cele_date.innerHTML
=temp_str;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值