<INPUT onfocus=setday(this) size=30 name=call_board_startdate> <script> document.writeln('<div id="meizzDateLayer" >'); document.writeln(' <span id="tmpSelectYearLayer" ></span>'); document.writeln(' <span id="tmpSelectMonthLayer" ></span>'); document.writeln(' <table border="0" cellspacing="1" cellpadding="0" width="100%" height="160" bgcolor="#808080" onselectstart="return false">'); document.writeln(' <tr>'); document.writeln(' <td width="100%" height="23" bgcolor="#FFFFFF">'); document.writeln(' <table border="0" cellspacing="1" cellpadding="0" width="100%" height="23">'); document.writeln(' <tr align="center">'); document.writeln(' <td width="25" align="center" bgcolor="#808080" '); document.writeln(' onclick="meizzPrevM()" title="向前翻月" Author="meizz"><b Author="meizz"><</b>'); document.writeln(' </td>'); document.writeln(' <td width="" align="center" Author="meizz">'); document.writeln(' <span Author="meizz" id="meizzYearHead" onclick="tmpSelectYearInnerHTML(this.innerText)"></span> 年 <span id="meizzMonthHead" Author="meizz" onclick="tmpSelectMonthInnerHTML(this.innerText)"></span> 月</td>'); document.writeln(' <td width="25" bgcolor="#808080" align="center" '); document.writeln(' onclick="meizzNextM()" title="往後翻月" Author="meizz"><b Author="meizz">></b></td>'); document.writeln(' </tr>'); document.writeln(' </table>'); document.writeln(' </td>'); document.writeln(' </tr>'); document.writeln(' <tr>'); document.writeln(' <td width="100%" height="18" bgcolor="#808080">'); document.writeln(' <table border="0" cellspacing="0" cellpadding="0" width="99%" height="1" >'); document.writeln(' <tr align="center">'); document.writeln(' <td Author="meizz">日</td>'); document.writeln(' <td Author="meizz">一</td>'); document.writeln(' <td Author="meizz">二</td>'); document.writeln(' <td Author="meizz">三</td>'); document.writeln(' <td Author="meizz">四</td>'); document.writeln(' <td Author="meizz">五</td>'); document.writeln(' <td Author="meizz">六</td>'); document.writeln(' </tr>'); document.writeln(' </table>'); document.writeln(' </td>'); document.writeln(' </tr>'); document.writeln(' <tr>'); document.writeln(' <td width="100%" height="120">'); document.writeln(' <table border="0" cellspacing="1" cellpadding="0" width="100%" height="120" bgcolor="#FFFFFF">'); var n=0;for (j=0;j<5;j++){ document.writeln('<tr align=center>'); for (i=0;i<7;i++){ document.writeln('<td width=20 height=20 id=meizzDay'+n+' style=font-size:12px Author=meizz onclick=meizzDayClick(this.innerText)></td>');n++;} document.writeln('</tr>');} document.writeln(' <tr align="center">'); document.writeln(' <td width="20" height="20" id="meizzDay35" Author="meizz" onclick="meizzDayClick(this.innerText)"></td>'); document.writeln(' <td width="20" height="20" id="meizzDay36" Author="meizz" onclick="meizzDayClick(this.innerText)"></td>'); document.writeln(' </tr>'); document.writeln(' </table>'); document.writeln(' </td>'); document.writeln(' </tr>'); document.writeln(' <tr>'); document.writeln(' <td>'); document.writeln(' <table border="0" cellspacing="1" cellpadding="0" width="100%" bgcolor="#FFFFFF">'); document.writeln(' <tr>'); document.writeln(' <td Author="meizz" align="left"><input Author="meizz" type="button" value="<<" title="向前翻年" onclick="meizzPrevY()" onfocus="this.blur()"'); document.writeln(' class="FlatButton2" ID="Button1" NAME="Button1"><input Author="meizz" title="向前翻月" type="button" value="<" onclick="meizzPrevM()" onfocus="this.blur()"'); document.writeln(' class="FlatButton2" ID="Utton1" NAME="Utton1"></td>'); document.writeln(' <td Author="meizz" align="center"><input Author="meizz" type="button" value="今天" onclick="meizzToday()" onfocus="this.blur()"'); document.writeln(' title="轉到今天的日期" class="FlatButton" ID="Button2" NAME="Button2"></td>'); document.writeln(' <td Author="meizz" align="right"><input Author="meizz" type="button" value=">" onclick="meizzNextM()" onfocus="this.blur()"'); document.writeln(' title="往後翻月" class="FlatButton2" ID="Button3" NAME="Button3"><input Author="meizz" type="button" value=">>" title="往後翻年" onclick="meizzNextY()" onfocus="this.blur()"'); document.writeln(' class="FlatButton2" ID="Button4" NAME="Button4"></td>'); document.writeln(' </tr>'); document.writeln(' </table>'); document.writeln(' </td>'); document.writeln(' </tr>'); document.writeln(' </table>'); document.writeln('<iframe src="javascript:false" progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";"></iframe>'); document.writeln('</div>'); document.writeln('<style type="text/css">'); document.writeln('.FlatButton {background-color: #f0f0f0; color: #000000;font-family:宋體;'); document.writeln(' font-size: 12px;position:relative;width:64px;height:20px;valign:top;cursor:hand;'); document.writeln(' border-left: 1px solid #DDDDDD; border-right: 1px solid #999999; '); document.writeln(' border-top: 1px solid #DDDDDD; border-bottom: 1px solid #999999 ;'); document.writeln(' }'); document.writeln(' .FlatButton2 {background-color: #f0f0f0; color: #000000;font-family:宋體;'); document.writeln(' font-size: 12px;position:relative;height:20px;valign:top;cursor:hand;'); document.writeln(' border-left: 1px solid #DDDDDD; border-right: 1px solid #999999; '); document.writeln(' border-top: 1px solid #DDDDDD; border-bottom: 1px solid #999999 ;'); document.writeln(' }'); document.writeln('</style>'); var outObject; function setday(tt,obj) //主調函數 { if (arguments.length > 2){alert("對不起!傳入本控制項的參數太多!");return;} if (arguments.length == 0){alert("對不起!您沒有傳回本控制項任何參數!");return;} var dads = document.all.meizzDateLayer.style;var th = tt; var ttop = tt.offsetTop; //TT控制項的錨點高 var thei = tt.clientHeight; //TT控制項本身的高 var tleft = tt.offsetLeft; //TT控制項的錨點寬 var ttyp = tt.type; //TT控制項的類型 while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;} dads.top = (ttyp=="image")? ttop+thei : ttop+thei+6; dads.left = tleft; outObject = (arguments.length == 1) ? th : obj; dads.display = ''; event.returnValue=false; } var MonHead = new Array(12); //定義陽曆中每個月的最大天數 MonHead[0] = 31; MonHead[1] = 28; MonHead[2] = 31; MonHead[3] = 30; MonHead[4] = 31; MonHead[5] = 30; MonHead[6] = 31; MonHead[7] = 31; MonHead[8] = 30; MonHead[9] = 31; MonHead[10] = 30; MonHead[11] = 31; var meizzTheYear=new Date().getFullYear(); //定義年的變數的初始值 var meizzTheMonth=new Date().getMonth()+1; //定義月的變數的初始值 var meizzWDay=new Array(37); //定義寫日期的數組 function document.onclick() //任意點擊時關閉該控制項 { with(window.event.srcElement) { if (tagName != "INPUT" && getAttribute("Author")==null) { document.all.meizzDateLayer.style.display="none"; //add on 2004-9-7 //begin if (document.getElementsByTagName("select")) { var obj; obj=document.getElementsByTagName("select"); for (i=0;i<obj.length;i++) { if (obj[i].style.display=="none") {obj[i].style.display="block";} } } //end } } } function meizzWriteHead(yy,mm) //往 head 中寫入當前的年與月 { document.all.meizzYearHead.innerText = yy; document.all.meizzMonthHead.innerText = mm; } function tmpSelectYearInnerHTML(strYear) //年份的下拉框 { if (strYear.match(/\D/)!=null){alert("年份輸入參數不是數字!");return;} var m = (strYear) ? strYear : new Date().getFullYear(); if (m < 1000 || m > 9999) {alert("年份值不在 1000 到 9999 之間!");return;} var n = m - 10; if (n < 1000) n = 1000; if (n + 26 > 9999) n = 9974; var s = "<select Author=meizz name=tmpSelectYear " s += "onblur='document.all.tmpSelectYearLayer.style.display=\"none\"' " s += "onchange='document.all.tmpSelectYearLayer.style.display=\"none\";" s += "meizzTheYear = this.value; meizzSetDay(meizzTheYear,meizzTheMonth)'>\r\n"; var selectInnerHTML = s; selectInnerHTML += "<option value='" + (n-10) + "'>" + "..." + "</option>\r\n"; for (var i = n; i < n + 26; i++) { if (i == m) {selectInnerHTML += "<option value='" + i + "' selected>" + i + "年" + "</option>\r\n";} else {selectInnerHTML += "<option value='" + i + "'>" + i + "年" + "</option>\r\n";} } selectInnerHTML += "<option value='" + (n+20) + "'>" + "..." + "</option>\r\n"; selectInnerHTML += "</select>"; document.all.tmpSelectYearLayer.style.display=""; document.all.tmpSelectYearLayer.innerHTML = selectInnerHTML; document.all.tmpSelectYear.focus(); } function tmpSelectMonthInnerHTML(strMonth) //月份的下拉框 { if (strMonth.match(/\D/)!=null){alert("月份輸入參數不是數字!");return;} var m = (strMonth) ? strMonth : new Date().getMonth() + 1; var s = "<select Author=meizz name=tmpSelectMonth " s += "onblur='document.all.tmpSelectMonthLayer.style.display=\"none\"' " s += "onchange='document.all.tmpSelectMonthLayer.style.display=\"none\";" s += "meizzTheMonth = this.value; meizzSetDay(meizzTheYear,meizzTheMonth)'>\r\n"; var selectInnerHTML = s; for (var i = 1; i < 13; i++) { if (i == m) {selectInnerHTML += "<option value='"+i+"' selected>"+i+"月"+"</option>\r\n";} else {selectInnerHTML += "<option value='"+i+"'>"+i+"月"+"</option>\r\n";} } selectInnerHTML += "</select>"; document.all.tmpSelectMonthLayer.style.display=""; document.all.tmpSelectMonthLayer.innerHTML = selectInnerHTML; document.all.tmpSelectMonth.focus(); } function closeLayer() //這個層的關閉 { document.all.meizzDateLayer.style.display="none"; } function document.onkeydown() { if (window.event.keyCode==27)document.all.meizzDateLayer.style.display="none"; } function IsPinYear(year) //判斷是否閏平年 { if (0==year%4&&((year%100!=0)||(year%400==0))) return true;else return false; } function GetMonthCount(year,month) //閏年二月為29天 { var c=MonHead[month-1];if((month==2)&&IsPinYear(year)) c++;return c; } function GetDOW(day,month,year) //求某天的星期幾 { var dt=new Date(year,month-1,day).getDay()/7; return dt; } function meizzPrevY() //往前翻 Year { if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear--;} else{alert("年份超出範圍(1000-9999)!");} meizzSetDay(meizzTheYear,meizzTheMonth); } function meizzNextY() //往後翻 Year { if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear++;} else{alert("年份超出範圍(1000-9999)!");} meizzSetDay(meizzTheYear,meizzTheMonth); } function meizzToday() //Today Button { meizzTheYear = new Date().getFullYear(); meizzTheMonth = new Date().getMonth()+1; meizzSetDay(meizzTheYear,meizzTheMonth); } function meizzPrevM() //往前翻月份 { if(meizzTheMonth>1){meizzTheMonth--}else{meizzTheYear--;meizzTheMonth=12;} meizzSetDay(meizzTheYear,meizzTheMonth); } function meizzNextM() //往後翻月份 { if(meizzTheMonth==12){meizzTheYear++;meizzTheMonth=1}else{meizzTheMonth++} meizzSetDay(meizzTheYear,meizzTheMonth); } function meizzSetDay(yy,mm) //主要的寫程式********** { meizzWriteHead(yy,mm); for (var i = 0; i < 37; i++){meizzWDay[i]=""}; //將顯示框的內容全部清空 var day1 = 1,firstday = new Date(yy,mm-1,1).getDay(); //某月第一天的星期幾 for (var i = firstday; day1 < GetMonthCount(yy,mm)+1; i++){meizzWDay[i]=day1;day1++;} for (var i = 0; i < 37; i++) { var da = eval("document.all.meizzDay"+i) //書寫新的一個月的日期星期排列 if (meizzWDay[i]!="") { da.innerHTML = "<b>" + meizzWDay[i] + "</b>"; da.style.backgroundColor = (yy == new Date().getFullYear() && mm == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate()) ? "#FFD700" : "#ADD8E6"; da.style.cursor="hand" } else{da.innerHTML="";da.style.backgroundColor="";da.style.cursor="default"} } } function meizzDayClick(n) //點擊顯示框選取日期,主輸入函數************* { var yy = meizzTheYear; var mm = meizzTheMonth; if (mm < 10){mm = "0" + mm;} if (outObject) { if (!n) {outObject.value=""; return;} if ( n < 10){n = "0" + n;} outObject.value= yy + "-" + mm + "-" + n ; //註:在這裡你可以輸出改成你想要的格式 closeLayer(); } else {closeLayer(); alert("您所要輸出的控制項對象並不存在!");} } meizzSetDay(meizzTheYear,meizzTheMonth) </script>
[Ctrl+A 全選 注:如需引入外部Js需重新整理才能執行]