datechoice.js
上传用户:huijianzhu
上传日期:2009-11-25
资源大小:9825k
文件大小:11k
源码类别:

电子政务应用

开发平台:

Java

  1. <!--
  2. document.writeln('<div id=meizzDateLayer style="position: absolute; width: 142; height: 166; z-index: 9998; display: none">');
  3. document.writeln('<span id=tmpSelectYearLayer  style="z-index: 9999;position: absolute;top: 2; left: 18;display: none"></span>');
  4. document.writeln('<span id=tmpSelectMonthLayer style="z-index: 9999;position: absolute;top: 2; left: 75;display: none"></span>');
  5. document.writeln('<table border=0 cellspacing=1 cellpadding=0 width=142 height=160 bgcolor=#808080 onselectstart="return false">');
  6. document.writeln('  <tr><td width=142 height=23 bgcolor=#FFFFFF><table border=0 cellspacing=1 cellpadding=0 width=140 height=23>');
  7. document.writeln('      <tr align=center><td width=20 align=center bgcolor=#808080 style="font-size:12px;cursor: hand;color: #FFD700" ');
  8. document.writeln('        onclick="meizzPrevM()" title="向前翻1月" Author=meizz><b Author=meizz>&lt;&nbsp;</b>');
  9. document.writeln('        </td><td width=100 align=center style="font-size:12px;cursor:default" Author=meizz>');
  10. //document.writeln('        <span Author=meizz id=meizzYearHead onclick="tmpSelectYearInnerHTML(this.innerText)"></span>&nbsp;年&nbsp;<span');
  11. document.writeln('        <span Author=meizz id=meizzYearHead onmouseover="style.backgroundColor='yellow'" onmouseout="style.backgroundColor='white'" title="点击这里选择年份" onclick="tmpSelectYearInnerHTML(this.innerText)"></span>&nbsp;年&nbsp;<span');
  12. //document.writeln('         id=meizzMonthHead Author=meizz onclick="tmpSelectMonthInnerHTML(this.innerText)"></span>&nbsp;月</td>');
  13. document.writeln('         id=meizzMonthHead Author=meizz onmouseover="style.backgroundColor='yellow'" onmouseout="style.backgroundColor='white'" title="点击这里选择月份" onclick="tmpSelectMonthInnerHTML(this.innerText)"></span>&nbsp;月</td>');
  14. document.writeln('        <td width=20 bgcolor=#808080 align=center style="font-size:12px;cursor: hand;color: #FFD700" ');
  15. document.writeln('         onclick="meizzNextM()" title="往后翻1月" Author=meizz><b Author=meizz>&nbsp;&gt;</b></td></tr>');
  16. document.writeln('    </table></td></tr>');
  17. document.writeln('  <tr><td width=142 height=18 bgcolor=#808080>');
  18. document.writeln('<table border=0 cellspacing=0 cellpadding=0 width=140 height=1 style="cursor:default">');
  19. document.writeln('<tr align=center><td style="font-size:12px;color:#FFFFFF" Author=meizz>日</td>');
  20. document.writeln('<td style="font-size:12px;color:#FFFFFF" Author=meizz>一</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>二</td>');
  21. document.writeln('<td style="font-size:12px;color:#FFFFFF" Author=meizz>三</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>四</td>');
  22. document.writeln('<td style="font-size:12px;color:#FFFFFF" Author=meizz>五</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>六</td></tr>');
  23. document.writeln('</table></td></tr><!-- Author:F.R.Huang(meizz)meizz @ hzcnc.com 2002-10-8 -->');
  24. document.writeln('  <tr><td width=142 height=120>');
  25. document.writeln('    <table border=0 cellspacing=1 cellpadding=0 width=140 height=120 bgcolor=#FFFFFF>');
  26. var n=0; for (j=0;j<5;j++){ document.writeln (' <tr align=center>'); for (i=0;i<7;i++){
  27. document.writeln('<td width=20 height=20 id=meizzDay'+n+' style="font-size:12px" Author=meizz onclick=meizzDayClick(this.innerText)></td>');n++;}
  28. document.writeln('</tr>');}
  29. document.writeln('      <tr align=center><td width=20 height=20 style="font-size:12px" id=meizzDay35 Author=meizz ');
  30. document.writeln('         onclick=meizzDayClick(this.innerText)></td>');
  31. document.writeln('        <td width=20 height=20 style="font-size:12px" id=meizzDay36 Author=meizz onclick=meizzDayClick(this.innerText)></td>');
  32. document.writeln('        <td colspan=5 align=right Author=meizz><span onclick=closeLayer() style="font-size:12px;cursor: hand"');
  33. document.writeln('         Author=meizz title="作者: OTT&#13;"><u>关闭本控件</u></span>&nbsp;</td></tr>');
  34. document.writeln('    </table></td></tr><tr><td>');
  35. document.writeln('        <table border=0 cellspacing=1 cellpadding=0 width=100% bgcolor=#FFFFFF>');
  36. document.writeln('          <tr><td Author=meizz align=left><input Author=meizz type=button value="<<" title="向前翻1年" onclick="meizzPrevY()" ');
  37. document.writeln('             onfocus="this.blur()" style="font-size: 12px; height: 20px"><input Author=meizz title="向前翻1月" type=button ');
  38. document.writeln('             value="< " onclick="meizzPrevM()" onfocus="this.blur()" style="font-size: 12px; height: 20px"></td><td ');
  39. document.writeln('             Author=meizz align=center><input Author=meizz type=button value="今天" onclick="meizzToday()" ');
  40. document.writeln('             onfocus="this.blur()" title="现在的年月" style="font-size: 12px; height: 20px"></td><td ');
  41. document.writeln('             Author=meizz align=right><input Author=meizz type=button value=" >" onclick="meizzNextM()" ');
  42. document.writeln('             onfocus="this.blur()" title="往后翻1月" style="font-size: 12px; height: 20px"><input ');
  43. document.writeln('             Author=meizz type=button value=">>" title="往后翻1年" onclick="meizzNextY()"');
  44. document.writeln('             onfocus="this.blur()" style="font-size: 12px; height: 20px"></td>');
  45. document.writeln('</tr></table></td></tr></table></div>');
  46. var outObject;
  47. function setday(tt,obj) {
  48. if (arguments.length >  2){alert("对不起!传入本控件的参数太多!");return;}
  49. if (arguments.length == 0){alert("对不起!您没有传回本控件任何参数!");return;}
  50. var dads  = document.all.meizzDateLayer.style;var th = tt;
  51. var ttop  = tt.offsetTop;     
  52. var thei  = tt.clientHeight;  
  53. var tleft = tt.offsetLeft;    
  54. var ttyp  = tt.type;          
  55. while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;}
  56. dads.top  = (ttyp=="image")? ttop+thei : ttop+thei+6;
  57. dads.left = tleft;
  58. outObject = (arguments.length == 1) ? th : obj;
  59. dads.display = '';
  60. event.returnValue=false;
  61. }
  62. var MonHead = new Array(12);         
  63. MonHead[0] = 31; MonHead[1] = 28; MonHead[2] = 31; MonHead[3] = 30; MonHead[4]  = 31; MonHead[5]  = 30;
  64. MonHead[6] = 31; MonHead[7] = 31; MonHead[8] = 30; MonHead[9] = 31; MonHead[10] = 30; MonHead[11] = 31;
  65. var meizzTheYear=new Date().getFullYear(); 
  66. var meizzTheMonth=new Date().getMonth()+1; 
  67. var meizzWDay=new Array(37);
  68. function document.onclick() { 
  69. with(window.event.srcElement) { 
  70. if (getAttribute("Author")==null && tagName != "INPUT")
  71. document.all.meizzDateLayer.style.display="none";
  72. }
  73. }
  74. function meizzWriteHead(yy,mm) { 
  75. document.all.meizzYearHead.innerText  = yy;
  76. document.all.meizzMonthHead.innerText = mm;
  77. }
  78. function tmpSelectYearInnerHTML(strYear) {
  79. if (strYear.match(/D/)!=null){alert("年份输入参数不是数字!");return;}
  80. var m = (strYear) ? strYear : new Date().getFullYear();
  81. if (m < 1000 || m > 9999) {alert("年份值不在 1000 到 9999 之间!");return;}
  82. var n = m - 10;
  83. if (n < 1000) n = 1000;
  84. if (n + 26 > 9999) n = 9974;
  85. var s = "<select Author=meizz name=tmpSelectYear style='font-size: 12px' "
  86. s += "onblur='document.all.tmpSelectYearLayer.style.display="none"' "
  87. s += "onchange='document.all.tmpSelectYearLayer.style.display="none";"
  88. s += "meizzTheYear = this.value; meizzSetDay(meizzTheYear,meizzTheMonth)'>rn";
  89. var selectInnerHTML = s;
  90. for (var i = n; i < n + 26; i++)
  91. {
  92. if (i == m) {
  93. selectInnerHTML += "<option value='" + i + "' selected>" + i + "年" + "</option>rn";
  94. }
  95. else {
  96. selectInnerHTML += "<option value='" + i + "'>" + i + "年" + "</option>rn";
  97. }
  98. }
  99. selectInnerHTML += "</select>";
  100. document.all.tmpSelectYearLayer.style.display="";
  101. document.all.tmpSelectYearLayer.innerHTML = selectInnerHTML;
  102. document.all.tmpSelectYear.focus();
  103. }
  104. function tmpSelectMonthInnerHTML(strMonth) {
  105. if (strMonth.match(/D/)!=null){alert("月份输入参数不是数字!");return;}
  106. var m = (strMonth) ? strMonth : new Date().getMonth() + 1;
  107. var s = "<select Author=meizz name=tmpSelectMonth style='font-size: 12px' "
  108. s += "onblur='document.all.tmpSelectMonthLayer.style.display="none"' "
  109. s += "onchange='document.all.tmpSelectMonthLayer.style.display="none";"
  110. s += "meizzTheMonth = this.value; meizzSetDay(meizzTheYear,meizzTheMonth)'>rn";
  111. var selectInnerHTML = s;
  112. for (var i = 1; i < 13; i++)
  113. {
  114. if (i == m) {
  115. selectInnerHTML += "<option value='"+i+"' selected>"+i+"月"+"</option>rn";
  116. }
  117. else {selectInnerHTML += "<option value='"+i+"'>"+i+"月"+"</option>rn";}
  118. }
  119. selectInnerHTML += "</select>";
  120. document.all.tmpSelectMonthLayer.style.display="";
  121. document.all.tmpSelectMonthLayer.innerHTML = selectInnerHTML;
  122. document.all.tmpSelectMonth.focus();
  123. }
  124. function closeLayer() {
  125. document.all.meizzDateLayer.style.display="none";
  126. }
  127. function document.onkeydown() {
  128. if (window.event.keyCode==27)document.all.meizzDateLayer.style.display="none";
  129. }
  130. function IsPinYear(year) {
  131. if (0==year%4&&((year%100!=0)||(year%400==0))) return true;else return false;
  132. }
  133. function GetMonthCount(year,month) {
  134. var c=MonHead[month-1];if((month==2)&&IsPinYear(year)) c++;return c;
  135. }
  136. function GetDOW(day,month,year) {
  137. var dt=new Date(year,month-1,day).getDay()/7; return dt;
  138. }
  139. function meizzPrevY() {
  140. if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear--;}
  141. else{alert("年份超出范围(1000-9999)!");}
  142. meizzSetDay(meizzTheYear,meizzTheMonth);
  143. }
  144. function meizzNextY() {
  145. if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear++;}
  146. else{alert("年份超出范围(1000-9999)!");}
  147. meizzSetDay(meizzTheYear,meizzTheMonth);
  148. }
  149. function meizzToday() {
  150. meizzTheYear = new Date().getFullYear();
  151. meizzTheMonth = new Date().getMonth()+1;
  152. meizzSetDay(meizzTheYear,meizzTheMonth);
  153. }
  154. function meizzPrevM() {
  155. if(meizzTheMonth>1){meizzTheMonth--}else{meizzTheYear--;meizzTheMonth=12;}
  156. meizzSetDay(meizzTheYear,meizzTheMonth);
  157. }
  158. function meizzNextM() {
  159. if(meizzTheMonth==12){meizzTheYear++;meizzTheMonth=1}else{meizzTheMonth++}
  160. meizzSetDay(meizzTheYear,meizzTheMonth);
  161. }
  162. function meizzSetDay(yy,mm) {
  163. meizzWriteHead(yy,mm);
  164. for (var i = 0; i < 37; i++){meizzWDay[i]=""};
  165. var day1 = 1,firstday = new Date(yy,mm-1,1).getDay(); 
  166. for (var i = firstday; day1 < GetMonthCount(yy,mm)+1; i++){meizzWDay[i]=day1;day1++;}
  167. for (var i = 0; i < 37; i++) { 
  168. var da = eval("document.all.meizzDay"+i)   
  169. if (meizzWDay[i]!="") { 
  170. da.innerHTML = "<b>" + meizzWDay[i] + "</b>";
  171. da.style.backgroundColor = (yy == new Date().getFullYear() &&
  172. mm == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate()) ? "#FFD700" : "#ADD8E6";
  173. da.style.cursor="hand"
  174. }
  175. else{da.innerHTML="";da.style.backgroundColor="";da.style.cursor="default"}
  176. }
  177. }
  178. function meizzDayClick(n) 
  179. {
  180. var yy = meizzTheYear;
  181. var mm = meizzTheMonth;
  182. if (mm < 10){mm = "0" + mm;}
  183. if (outObject)
  184. {
  185. if (!n) {outObject.value=""; return;}
  186. if ( n < 10){n = "0" + n;}
  187. outObject.value= yy + "-" + mm + "-" + n ;
  188. closeLayer(); 
  189. }
  190. else {
  191. closeLayer(); alert("您所要输出的控件对象并不存在!");
  192. }
  193. }
  194. meizzSetDay(meizzTheYear,meizzTheMonth);
  195. // -->