<div class="codetitle"> <span><a style="CURSOR: pointer" data="31896" class="copybut" id="copybut31896" onclick="doCopy('code31896')"><u>코드 복사</u></a></span> 코드는 다음과 같습니다.</div> <div class="codebody" id="code31896"> <br><html> <br><머리> <br><title>很漂亮、兼容fire狐的Js日期选择,自动填充到输入框</title> <br><meta http-equiv="content-Type" content="text/html;charset=gb2312"> <br><style type="text/css"> <br>body{font-size:12px;font-family:Verdana,Arial,"宋体";} <br>a:link {color:#464646;text-꾸밈:none;} <br>a:visited { 색상:#464646;텍스트 장식:없음;} <br>a:hover{color:#ed145b;텍스트-장식:밑줄;} <br>a:활성{color:#ed145b;text-장식:밑줄;} <br>td{font-size:12px} <br>/*/*/ <br>/*DateCSS样式*/ <br>.header {font: 12px Arial, Tahoma !important;font-weight: 굵은 글씨 !important ;글꼴: 11px Arial, Tahoma;글꼴-가중치: 굵게;색상: #154BA0;배경:#C2DEED;높이: 25px;왼쪽 여백: 10px; <br>} <br>.header td {padding-left: 10px;} <br>.header a {color: #154BA0;} <br>.header input {배경:none;vertical-align: middle;height: 16px;} <br>.category {글꼴: 12px Arial, Tahoma !important;font: 11px Arial, Tahoma;color: #92A05A;height:20px; background-color: #FFFFD9;} <br>.category td {border -하단: 1px 솔리드 #DEDEB8;} <br>.expire, .expire a:link, .expire a:visited {color: #999999;} <br>.default, .default a:link, .default a:visited {색상: #000000;} <br>.checked, .checked a:link, .checked a:visited {color: #FF0000;} <br>.today, .today a:link, .today a:visited {color : #00BB00;} <br>#calendar_year {표시: 없음; 줄 높이: 130%;배경: #FFFFFF;위치: 절대;z-색인: 10;} <br>#calendar_year .col {float: 왼쪽; 배경: #FFFFFF;왼쪽 여백: 1px;테두리: 1px 실선 #86B9D6;패딩: 4px;} <br>#calendar_month {디스플레이: 없음;배경: #FFFFFF;줄 높이: 130%;테두리: 1px 실선 # 86B9D6;패딩: 4px;위치: 절대;z-색인: 11;} <br>.tableborder {배경: 흰색;border: 1px 솔리드 #86B9D6;} <br>#연도,#월{패딩-오른쪽:10px; } <br></style> <br><스크립트 언어="javascript"> <br>//하위 인터페이스에는 다음이 있습니다. <br>var ie =navigator.appName=="Microsoft Internet Explorer"?true:false; <br>function $(objID){ <br>return document.getElementById(objID); <br>} <br></script> <br></head> <br><본문> <br><br><script type="text/javascript"> <br>var 제어 ID = null; <br>var curdate = null; <br>var startdate = null; <br>var enddate = null; <br>var yy = null; <br>var mm = null; <br>var hh = null; <br>var ii = null; <br>var curday = null; <br>var addtime = false; <br>var today = new Date(); <br>var lastcheckedyear = false; <br>var lastcheckedmonth = false; <br>function _cancelBubble(event) { <br>e = 이벤트 ? 이벤트 : window.event ; <br>if(ie) { <br>e.cancelBubble = true; <br>} else { <br>e.stopPropagation(); <br>} <br>} <br>function getposition(obj) { <br>var r = new Array(); <br>r['x'] = obj.offsetLeft; <br>r['y'] = obj.offsetTop; <br>while(obj = obj.offsetParent) { <br>r['x'] = obj.offsetLeft; <br>r['y'] = obj.offsetTop; <br>} <br>r을 반환합니다. <br>} <br>function loadcalendar() { <br>s = ''; <br>s = '<div id="calendar" style="display:none; position:absolute; z-index:9;" onclick="_cancelBubble(event)">'; <br>if (즉) <br>{ <br>s = '<iframe width="200" height="160" src="about:blank" style="위치: 절대;z-index:-1 ;"></iframe>'; <br>} <br>s = '<div style="width: 200px;"><table class="tableborder"cellspacing="0" cellpadding="0" width="100%" style=" 텍스트 정렬: 가운데">'; <br>/// <br>s = '<tr align="center" class="header"><td class="header"><a href="#" onclick="refreshcalendar( yy, mm-1);return false" title="上一月"><<</a></td><td colspan="5" style="text-align: center" class="header"><a href="#" onclick="showdiv('year');_cancelBubble(event);return false" title="点击选择年份" id="year"></ a> - <a id="month" title="点击选择月份" href="#" onclick="showdiv('month');_cancelBubble(event);return false"></a></td> ;<td class="header"><A href="#" onclick="refreshcalendar(yy, mm 1);return false" title="下一月">>></A> ;</td></tr>'; <br>s = '<tr class="category"><td>일</td><td>일</td><td>이</td><td> 3</td><td>4</td><td>5</td><td>六</td></tr>'; <br>for(var i = 0; i < 6; i ) { <BR>s = '<tr class="altbg2">'; <br>for(var j = 1; j s = "<td id=d" (i * 7 j) " height="19">0</td> "; <br>s = "</tr>"; <br>} <br>s += '<tr id="hourminute"><td colspan="7" align="center"><input type="text" size="1" value="" id="hour" onKeyUp=\'this.value=this.value > 23 ? 23 : zerofill(this.value);controlid.value=controlid.value.replace(/\\d+(\:\\d+)/ig, this.value+"$1")\'> 点 <input type="text" size="1" value="" id="minute" onKeyUp=\'this.value=this.value > 59 ? 59 : zerofill(this.value);controlid.value=controlid.value.replace(/(\\d+\:)\\d+/ig, "$1"+this.value)\'> 分</td></tr>'; <br>s += '</table></div></div>';/// <br>s += '<div id="calendar_year" onclick="_cancelBubble(event)"><div class="col">'; <br>for(var k = 1930; k <= 2019; k++) { <br>s += k != 1930 && k % 10 == 0 ? '</div><div class="col">' : ''; <br>s += '<a href="#" onclick="refreshcalendar(' + k + ', mm);$(\'calendar_year\').style.display=\'none\';return false"><span' + (today.getFullYear() == k ? ' class="today"' : '') + ' id="calendar_year_' + k + '">' + k + '</span></a><br />'; <br>} <br>s += '</div></div>'; <br>s += '<div id="calendar_month" onclick="_cancelBubble(event)">'; <br>for(var k = 1; k <= 12; k++) { <BR>s += '<a href="#" onclick="refreshcalendar(yy, ' + (k - 1) + ');$(\'calendar_month\').style.display=\'none\';return false"><span' + (today.getMonth()+1 == k ? ' class="today"' : '') + ' id="calendar_month_' + k + '">' + k + ( k < 10 ? ' ' : '') + ' 月</span></a><br />'; <br>} <br>s += '</div>'; <br>var nElement = document.createElement("div"); <br>nElement.innerHTML=s; <br>document.getElementsByTagName("body")[0].appendChild(nElement); <br>//document.write(s); <br>document.onclick = function(event) { <br>$('calendar').style.display = 'none'; <br>$('calendar_year').style.display = '없음'; <br>$('calendar_month').style.display = '없음'; <br>} <br>$('calendar').onclick = function(event) { <br>_cancelBubble(event); <br>$('calendar_year').style.display = '없음'; <br>$('calendar_month').style.display = '없음'; <br>} <br>} <br>함수 구문 분석 날짜(들) { <br>/(d )-(d )-(d )s*(d*):?(d*)/.exec(s) ; <br>var m1 = (RegExp.$1 && RegExp.$1 > 1899 && RegExp.$1 < 2101) ? parseFloat(RegExp.$1) : today.getFullYear(); <BR>var m2 = (RegExp.$2 && (RegExp.$2 > 0 && RegExp.$2 < 13)) ? parseFloat(RegExp.$2) : today.getMonth() 1; <BR>var m3 = (RegExp.$3 && (RegExp.$3 > 0 && RegExp.$3 < 32)) ? parseFloat(RegExp.$3) : today.getDate(); <BR>var m4 = (RegExp.$4 && (RegExp.$4 > -1 && RegExp.$4 < 24)) ? parsFloat(RegExp.$4) : 0; <BR>var m5 = (RegExp.$5 && (RegExp.$5 > -1 && RegExp.$5 < 60)) ? parsFloat(RegExp.$5) : 0; <BR>/(d )-(d )-(d )s*(d*):?(d*)/.exec("0000-00-00 00:00"); <BR>새 날짜 반환(m1, m2 - 1, m3, m4, m5); <BR>} <BR>function settime(d) { <BR>$('calendar').style.display = 'none'; <BR>controlid.value = yy "-" zerofill(mm 1) "-" zerofill(d) (addtime ? ' ' zerofill($('hour').value) ':' zerofill($('분') .값) : ''); <BR>} <BR>function showcalendar(event, controlid1, addtime1, startdate1, enddate1) { <BR>controlid = controlid1; <BR>추가시간 = 추가시간1; <BR>startdate = startdate1 ? 구문 분석(startdate1) : 거짓; <BR>종료일 = 종료일1 ? 구문 분석(enddate1) : false; <BR>currday = controlid.value ? 구문 분석(controlid.value) : 오늘; <BR>hh = currday.getHours(); <BR>ii = currday.getMinutes(); <BR>var p = getposition(controlid); <BR>$('calendar').style.display = '차단'; <BR>$('calendar').style.left = p['x'] 'px'; <BR>$('calendar').style.top = (p['y'] 20) 'px'; <BR>_cancelBubble(이벤트); <BR>refreshcalendar(currday.getFullYear(), currday.getMonth()); <BR>if(lastcheckedyear != false) { <BR>$('calendar_year_' lastcheckedyear).className = 'default'; <BR>$('calendar_year_' today.getFullYear()).className = '오늘'; <BR>} <BR>if(lastcheckedmonth != false) { <BR>$('calendar_month_' lastcheckedmonth).className = 'default'; <BR>$('calendar_month_' (today.getMonth() 1)).className = '오늘'; <BR>} <BR>$('calendar_year_' currday.getFullYear()).className = 'checked'; <BR>$('calendar_month_' (currday.getMonth() 1)).className = 'checked'; <BR>$('hourmin').style.display = addtime ? '' : '없음'; <BR>lastcheckedyear = currday.getFullYear(); <BR>lastcheckedmonth = currday.getMonth() 1; <BR>} <BR>function Refreshcalendar(y, m) { <BR>var x = new Date(y, m, 1); <BR>var mv = x.getDay(); <BR>var d = x.getDate(); <BR>var dd = null; <BR>yy = x.getFullYear(); <BR>mm = x.getMonth(); <BR>$("연도").innerHTML = yy; <BR>$("월").innerHTML = mm 1 > 9? (mm 1) : '0' (mm 1); <br>for(var i = 1; i <= mv; i ) { <BR>dd = $("d" i); <BR>dd.innerHTML = " "; <BR>dd.className = ""; <BR>} <BR>while(x.getMonth() == mm) { <BR>dd = $("d" (d mv)); <BR>dd.innerHTML = '<a href="###" onclick="settime(' d ');return false">' d '</a>'; <br>if(x.getTime() < today.getTime() || (enddate && x.getTime() > enddate.getTime()) || (startdate && x.getTime() < startdate.getTime ())) { <br>dd.className = '만료'; <br>} else { <br>dd.className = '기본값'; <br>} <br>if(x.getFullYear() == today.getFullYear() && x.getMonth() == today.getMonth() && x.getDate() == today.getDate()) { <br>dd.className = '오늘'; <br>dd.firstChild.title = '일천'; <br>} <br>if(x.getFullYear() == currday.getFullYear() && x.getMonth() == currday.getMonth() && x.getDate() == currday.getDate()) { <br>dd.className = '확인됨'; <br>} <br>x.setDate(d); <br>} <br>while(d mv <= 42) { <br>dd = $("d" (d mv)); <br>dd.innerHTML = " "; <br>d ; <br>} <br>if(addtime) { <br>$('hour').value = zerofill(hh); <br>$('분').value = zerofill(ii); <br>} <br>} <br>function showdiv(id) { <br>var p = getposition($(id)); <br>$('calendar_' id).style.left = p['x'] 'px'; <br>$('calendar_' id).style.top = (p['y'] 16) 'px'; <br>$('calendar_' id).style.display = '차단'; <br>} <br>function zerofill(s) { <br>var s = parsFloat(s.toString().replace(/(^[s0] )|(s $)/g, '')); <br>s = isNaN(들) ? 0 : 초; <br>return (s < 10 ? '0' : '') s.toString(); <br>}<br>loadcalendar(); <br></script> <br>사용법演示:<br>请选择日期:<input name="member.birth" type="text" value="2008-5-19" size="14" readonly onclick="showcalendar(event ,이것);" onfocus="showcalendar(event, this);if(this.value=='0000-00-00')this.value=''"> <br></body> <br></html> <br> </div>