User_Info_Modify.js
上传用户:apresys
上传日期:2021-03-30
资源大小:813k
文件大小:8k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

DOS

  1. //日历
  2. var date_start,date_end,g_object
  3. var today = new Date();
  4. var separator="-";
  5. var inover=false;
  6. //mode :时间变换的类型0-年 1-月 2-直接选择月
  7. function change_date(temp,mode)
  8. {
  9. var t_month,t_year
  10.     if (mode){
  11.         if(mode==1)
  12.         t_month=parseInt(cele_date_month.value,10)+parseInt(temp,10);
  13.         else
  14.         t_month=parseInt(temp)
  15.         if (t_month<cele_date_month.options(0).text) {
  16.             cele_date_month.value=cele_date_month.options(cele_date_month.length-1).text;
  17.             change_date(parseInt(cele_date_year.value,10)-1,0);
  18.             }
  19.         else{
  20.             if (t_month>cele_date_month.options(cele_date_month.length-1).text){
  21.                 cele_date_month.value=cele_date_month.options(0).text;
  22.                 change_date(parseInt(cele_date_year.value,10)+1,0);
  23.                 }            
  24.             else
  25.                 {cele_date_month.value=t_month;
  26.                  set_cele_date(cele_date_year.value,cele_date_month.value);                
  27.                 }
  28.         }
  29.     }  
  30.     else{
  31.         t_year=parseInt(temp,10);
  32.         
  33.         if (t_year<cele_date_year.options(0).text) {
  34.             cele_date_year.value=cele_date_year.options(0).text;
  35.             set_cele_date(cele_date_year.value,1);                
  36.             }
  37.         else{
  38.             if (parseInt(t_year,10)>parseInt(cele_date_year.options(cele_date_year.length-1).text,10)){
  39.                 cele_date_year.value=cele_date_year.options(cele_date_year.length-1).text;
  40.                 set_cele_date(cele_date_year.value,12);                
  41.                 }            
  42.             else
  43.                 {cele_date_year.value=t_year;
  44.                  set_cele_date(cele_date_year.value,cele_date_month.value);                
  45.                 }
  46.         }
  47.     }
  48.     /*********2002-02-01 MODIFY BY WING **************/
  49.     window.cele_date.focus();
  50.     /****************MODIFY END***********************/
  51. }
  52. //初始化日历
  53. function init(d_start,d_end)
  54. {
  55.      var temp_str;
  56.      var i=0
  57.      var j=0
  58.      date_start=new Date(1980,7,1)
  59.      date_end=new Date(2004,8,1)
  60.      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>");
  61.      window.cele_date.innerHTML="";
  62.      temp_str="<table border="1" bgcolor="#DDDDDD" bordercolor="white"><tr><td colspan=7 onmouseover="overcolor(this)">";
  63.      temp_str+="<input type="Button" value="<<" onclick="change_date(-1,1)" onmouseover="getlayerfocus()" style="color: #000099; background-color: #BFBFBF; cursor: hand">-";
  64.      temp_str+=""
  65.      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: 1px #666666 outset; background-color: #F4F8FB">"
  66.      for (i=1900;i<=2020;i++)
  67.      {
  68.       temp_str+="<OPTION value=""+i.toString()+"">"+i.toString()+"</OPTION>";
  69.      }
  70.      temp_str+="</select>-";
  71.      temp_str+=""
  72.      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: 1px #666666 outset; background-color: #F4F8FB">"
  73.      for (i=1;i<=12;i++)
  74.      {
  75.       temp_str+="<OPTION value=""+i.toString()+"">"+i.toString()+"</OPTION>";
  76.      }
  77.      temp_str+="</select>-";
  78.      temp_str+=""
  79.      temp_str+="<input type="Button" value=">>" onclick="change_date(1,1)" onmouseover="getlayerfocus()"  style="color: #000099; background-color: #BFBFBF; cursor: hand">";
  80.      temp_str+="</td></tr><tr><td onmouseover="overcolor(this)">"
  81.      temp_str+="<font color=red>日</font></td><td>";temp_str+="一</td><td>"; temp_str+="二</td><td>"; temp_str+="三</td><td>"
  82.      temp_str+="四</td><td>";temp_str+="五</td><td>"; temp_str+="六</td></tr>";
  83.      for (i=1 ;i<=6 ;i++)
  84.      {
  85.      temp_str+="<tr>";
  86.         for(j=1;j<=7;j++){
  87.             temp_str+="<td name="c"+i+"_"+j+""id="c"+i+"_"+j+"" style="CURSOR: hand" style="COLOR:#000000" language="javascript" onmouseover="overcolor(this)" onmouseout="outcolor(this)" onclick="td_click(this)">?</td>"
  88.             }
  89.      temp_str+="</tr>"        
  90.      }
  91.      temp_str+="</td></tr></table>";
  92.      window.cele_date.innerHTML=temp_str;
  93. }
  94. function set_cele_date(year,month)
  95. {
  96.    var i,j,p,k
  97.    var nd=new Date(year,month-1,1);
  98.    event.cancelBubble=true;
  99.    cele_date_year.value=year;
  100.    cele_date_month.value=month;   
  101.    k=nd.getDay()-1
  102.    var temp;
  103.    for (i=1;i<=6;i++)
  104.       for(j=1;j<=7;j++)
  105.       {
  106.       eval("c"+i+"_"+j+".innerHTML=""");
  107.       eval("c"+i+"_"+j+".bgColor="#DDDDDD"");
  108.       eval("c"+i+"_"+j+".style.cursor="hand"");
  109.       }
  110.    while(month-1==nd.getMonth())
  111.     { j=(nd.getDay() +1);
  112.       p=parseInt((nd.getDate()+k) / 7)+1;
  113.       eval("c"+p+"_"+j+".innerHTML="+"""+nd.getDate()+""");
  114.       if ((nd.getDate()==today.getDate())&&(cele_date_month.value==today.getMonth()+1)&&(cele_date_year.value==today.getYear())){
  115.         eval("c"+p+"_"+j+".bgColor="#EFFB64"");
  116.       }
  117.       if (nd>date_end || nd<date_start)
  118.       {
  119.       eval("c"+p+"_"+j+".bgColor="#FF9999"");
  120.       eval("c"+p+"_"+j+".style.cursor="text"");
  121.       }
  122.       nd=new Date(nd.valueOf() + 86400000)
  123.     }
  124. }
  125. //s_object:点击的对象;d_start-d_end有效的时间区段;需要存放值的控件;
  126. function show_cele_date(eP,d_start,d_end,t_object)
  127. {
  128. window.cele_date.style.display="";
  129. window.cele_date.style.zIndex=99
  130. var s,cur_d
  131. var eT = eP.offsetTop;  
  132. var eH = eP.offsetHeight+eT;  
  133. var dH = window.cele_date.style.pixelHeight;  
  134. var sT = document.body.scrollTop; 
  135. var sL = document.body.scrollLeft; 
  136. event.cancelBubble=true;
  137. window.cele_date.style.posLeft = event.clientX-event.offsetX+sL-5;  
  138. window.cele_date.style.posTop = event.clientY-event.offsetY+eH+sT-5;
  139. if (window.cele_date.style.posLeft+window.cele_date.clientWidth>document.body.clientWidth) window.cele_date.style.posLeft+=eP.offsetWidth-window.cele_date.clientWidth;
  140. if (d_start!=""){
  141.     if (d_start=="today"){
  142.         date_start=new Date(today.getYear(),today.getMonth(),today.getDate());
  143.     }else{
  144.         s=d_start.split(separator);
  145.         date_start=new Date(s[0],s[1]-1,s[2]);
  146.     }
  147. }else{
  148.     date_start=new Date(1900,1,1);
  149. }
  150. if (d_end!=""){
  151.     s=d_end.split(separator);
  152.     date_end=new Date(s[0],s[1]-1,s[2]);
  153. }else{
  154.     date_end=new Date(3000,1,1);
  155. }
  156. g_object=t_object
  157. cur_d=new Date()
  158. set_cele_date(cur_d.getYear(),cur_d.getMonth()+1);
  159. window.cele_date.style.display="block";
  160. window.cele_date.focus();
  161. }
  162. function td_click(t_object)
  163. {
  164. var t_d
  165. if (parseInt(t_object.innerHTML,10)>=1 && parseInt(t_object.innerHTML,10)<=31 ) 
  166. { t_d=new Date(cele_date_year.value,cele_date_month.value-1,t_object.innerHTML)
  167. if (t_d<=date_end && t_d>=date_start)
  168. {
  169. var year = cele_date_year.value;
  170. var month = cele_date_month.value;
  171. var day = t_object.innerHTML;
  172. g_object.value=year+separator+month+separator+day;
  173. window.cele_date.style.display="none";};
  174. }
  175. }
  176. function h_cele_date()
  177. {
  178. window.cele_date.style.display="none";
  179. }
  180. function overcolor(obj)
  181. {
  182.   if (obj.style.cursor=="hand") obj.style.color = "#FFFFFF";
  183.   inover=true;
  184.   window.cele_date.focus();
  185. }
  186. function outcolor(obj)
  187. {
  188. obj.style.color = "#000000";
  189. inover=false;
  190. }
  191. function getNow(o){
  192.     var Stamp=new Date();
  193.     var year = Stamp.getYear();
  194.     var month = Stamp.getMonth()+1;
  195.     var day = Stamp.getDate();
  196.     
  197.     o.value=year+separator+month+separator+day;
  198. }
  199. function hilayer()
  200. {
  201. if (inover==false)
  202. {
  203. var lay=document.all.cele_date;
  204. lay.style.display="none";
  205. }
  206. }
  207. function getlayerfocus()
  208. {
  209. inover=true;
  210. }
  211. function lostlayerfocus()
  212. {
  213. inover=false;
  214. }
  215. init();
  216. //日历结束