var Calendar = Class.create();
Calendar.prototype = {
initialize : function(e, obj) {
this.event = (e) ? e : window.event;
this.obj = obj;
this.today = this.today = new Date();
this.year = this.today.getFullYear();
this.month = this.today.getMonth();
this.date = 1;
this.dayIndex = new Array('일','월','화','수','목','금','토');
this.lastDate = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
this.calWin = window.open('', 'calendar', 'width=200,height=180,top='+(this.event.clientY+100)+',left='+this.event.clientX);
this.makeCal();
},
makeCal : function(type, addSub) {
this.newDate = new Date(this.year, this.month, this.date);
if(type && addSub) {
if(type == 'year') {
if(addSub == 'add') this.newDate.setFullYear(this.newDate.getFullYear()+1); else this.newDate.setFullYear(this.newDate.getFullYear()-1);
} else if(type == 'month') {
if(addSub == 'add') this.newDate.setMonth(this.newDate.getMonth()+1); else this.newDate.setMonth(this.newDate.getMonth()-1);
}
}
this.year = this.newDate.getFullYear();
this.month = this.newDate.getMonth();
this.day = this.newDate.getDay();
if(((this.year%4 == 0) && (this.year%100 != 0)) || (this.year%400 ==0)) {
this.lastDate[1] = 29;
} else {
this.lastDate[1] = 28;
}
_cal = this;
this.calsrc = "<table border='0' cellpadding='0' cellspacing='1' borderColor='#eeeeee' width='100%'>\n";
this.calsrc += "<tr>\n";
this.calsrc += "<td><span onClick=opener._cal.makeCal('year','sub')><<</span> <span onClick=opener._cal.makeCal('month','sub')><</span></td>\n";
this.calsrc += "<td>"+this.newDate.getFullYear()+"년 "+(this.month+1)+"월</td>\n";
this.calsrc += "<td><span onClick=opener._cal.makeCal('month','add')>></span> <span onClick=opener._cal.makeCal('year','add')>>></span></td>\n";
this.calsrc += "</tr>\n";
this.calsrc += "</table>\n";
this.calsrc += "<table border='0' cellpadding='0' cellspacing='1' borderColor='#eeeeee' width='100%'>\n";
this.calsrc += "<tr>\n";
for(i=0; i<this.dayIndex.length; i++) {
this.calsrc += "<td>"+this.dayIndex[i]+"</td>\n";
}
this.calsrc += "</tr>\n";
for(i=0; i<this.day+this.lastDate[this.newDate.getMonth()];i++) {
if(!(i%7)) {
this.calsrc += "</tr>\n";
this.calsrc += "<tr>\n";
}
if(i >= this.day) {
this.calsrc += "<td><span onClick=opener._cal.setDate('"+((i-this.day)+1)+"')>"+((i-this.day)+1)+"</td>\n";
} else {
this.calsrc += "<td></td>\n";
}
}
this.calsrc += "</tr>\n";
this.calsrc += "</table>\n";
this.calWin.document.open();
this.calWin.document.clear();
this.calWin.document.write(this.calsrc);
this.calWin.document.close();
},
fillZero : function(len, value) {
var value = value.toString();
var addLen = len - value.length;
for(i=0; i<addLen; i++) {
value = "0"+value;
}
return value;
},
setDate : function(day) {
$(this.obj).value = this.year+'-'+this.fillZero(2,this.month+1)+'-'+this.fillZero(2,day);
this.calWin.close();
}
}
<input type="text" name="date" id="date'><input type="button" onClick="new Calendar(event, 'date')" value="달력" />
이렇게 사용하면 됩니다.
급조하느라 부족한부분이 많습니다.
Calendar.prototype = {
initialize : function(e, obj) {
this.event = (e) ? e : window.event;
this.obj = obj;
this.today = this.today = new Date();
this.year = this.today.getFullYear();
this.month = this.today.getMonth();
this.date = 1;
this.dayIndex = new Array('일','월','화','수','목','금','토');
this.lastDate = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
this.calWin = window.open('', 'calendar', 'width=200,height=180,top='+(this.event.clientY+100)+',left='+this.event.clientX);
this.makeCal();
},
makeCal : function(type, addSub) {
this.newDate = new Date(this.year, this.month, this.date);
if(type && addSub) {
if(type == 'year') {
if(addSub == 'add') this.newDate.setFullYear(this.newDate.getFullYear()+1); else this.newDate.setFullYear(this.newDate.getFullYear()-1);
} else if(type == 'month') {
if(addSub == 'add') this.newDate.setMonth(this.newDate.getMonth()+1); else this.newDate.setMonth(this.newDate.getMonth()-1);
}
}
this.year = this.newDate.getFullYear();
this.month = this.newDate.getMonth();
this.day = this.newDate.getDay();
if(((this.year%4 == 0) && (this.year%100 != 0)) || (this.year%400 ==0)) {
this.lastDate[1] = 29;
} else {
this.lastDate[1] = 28;
}
_cal = this;
this.calsrc = "<table border='0' cellpadding='0' cellspacing='1' borderColor='#eeeeee' width='100%'>\n";
this.calsrc += "<tr>\n";
this.calsrc += "<td><span onClick=opener._cal.makeCal('year','sub')><<</span> <span onClick=opener._cal.makeCal('month','sub')><</span></td>\n";
this.calsrc += "<td>"+this.newDate.getFullYear()+"년 "+(this.month+1)+"월</td>\n";
this.calsrc += "<td><span onClick=opener._cal.makeCal('month','add')>></span> <span onClick=opener._cal.makeCal('year','add')>>></span></td>\n";
this.calsrc += "</tr>\n";
this.calsrc += "</table>\n";
this.calsrc += "<table border='0' cellpadding='0' cellspacing='1' borderColor='#eeeeee' width='100%'>\n";
this.calsrc += "<tr>\n";
for(i=0; i<this.dayIndex.length; i++) {
this.calsrc += "<td>"+this.dayIndex[i]+"</td>\n";
}
this.calsrc += "</tr>\n";
for(i=0; i<this.day+this.lastDate[this.newDate.getMonth()];i++) {
if(!(i%7)) {
this.calsrc += "</tr>\n";
this.calsrc += "<tr>\n";
}
if(i >= this.day) {
this.calsrc += "<td><span onClick=opener._cal.setDate('"+((i-this.day)+1)+"')>"+((i-this.day)+1)+"</td>\n";
} else {
this.calsrc += "<td></td>\n";
}
}
this.calsrc += "</tr>\n";
this.calsrc += "</table>\n";
this.calWin.document.open();
this.calWin.document.clear();
this.calWin.document.write(this.calsrc);
this.calWin.document.close();
},
fillZero : function(len, value) {
var value = value.toString();
var addLen = len - value.length;
for(i=0; i<addLen; i++) {
value = "0"+value;
}
return value;
},
setDate : function(day) {
$(this.obj).value = this.year+'-'+this.fillZero(2,this.month+1)+'-'+this.fillZero(2,day);
this.calWin.close();
}
}
<input type="text" name="date" id="date'><input type="button" onClick="new Calendar(event, 'date')" value="달력" />
이렇게 사용하면 됩니다.
급조하느라 부족한부분이 많습니다.
[이 게시물은 관리자님에 의해 2011-10-31 16:57:14 JavaScript에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8130 | 9년 전 | 577 | ||
| 8129 |
|
9년 전 | 695 | |
| 8128 | 9년 전 | 551 | ||
| 8127 |
|
9년 전 | 594 | |
| 8126 | 9년 전 | 532 | ||
| 8125 | 9년 전 | 782 | ||
| 8124 |
|
9년 전 | 542 | |
| 8123 | 9년 전 | 528 | ||
| 8122 | 9년 전 | 458 | ||
| 8121 | 9년 전 | 569 | ||
| 8120 | 9년 전 | 483 | ||
| 8119 | 9년 전 | 574 | ||
| 8118 |
|
9년 전 | 651 | |
| 8117 |
|
9년 전 | 418 | |
| 8116 |
PASKRAN
|
9년 전 | 475 | |
| 8115 | 9년 전 | 473 | ||
| 8114 |
kiplayer
|
9년 전 | 613 | |
| 8113 | 9년 전 | 469 | ||
| 8112 |
|
9년 전 | 581 | |
| 8111 | 9년 전 | 420 | ||
| 8110 | 9년 전 | 458 | ||
| 8109 | 9년 전 | 391 | ||
| 8108 |
|
9년 전 | 568 | |
| 8107 |
|
9년 전 | 455 | |
| 8106 |
|
9년 전 | 457 | |
| 8105 | 9년 전 | 488 | ||
| 8104 |
|
9년 전 | 452 | |
| 8103 |
|
9년 전 | 453 | |
| 8102 |
|
9년 전 | 426 | |
| 8101 |
snshero
|
9년 전 | 813 | |
| 8100 | 9년 전 | 858 | ||
| 8099 | 9년 전 | 837 | ||
| 8098 | 9년 전 | 741 | ||
| 8097 | 9년 전 | 544 | ||
| 8096 | 9년 전 | 745 | ||
| 8095 | 9년 전 | 881 | ||
| 8094 | 9년 전 | 550 | ||
| 8093 | 9년 전 | 830 | ||
| 8092 | 9년 전 | 778 | ||
| 8091 | 9년 전 | 1164 | ||
| 8090 | 9년 전 | 790 | ||
| 8089 | 9년 전 | 1000 | ||
| 8088 | 9년 전 | 662 | ||
| 8087 | 9년 전 | 791 | ||
| 8086 | 9년 전 | 538 | ||
| 8085 | 9년 전 | 504 | ||
| 8084 | 9년 전 | 623 | ||
| 8083 | 9년 전 | 595 | ||
| 8082 | 9년 전 | 785 | ||
| 8081 | 9년 전 | 497 | ||
| 8080 | 9년 전 | 593 | ||
| 8079 | 9년 전 | 550 | ||
| 8078 | 9년 전 | 468 | ||
| 8077 | 9년 전 | 557 | ||
| 8076 | 9년 전 | 428 | ||
| 8075 | 9년 전 | 459 | ||
| 8074 | 9년 전 | 426 | ||
| 8073 | 9년 전 | 479 | ||
| 8072 | 9년 전 | 473 | ||
| 8071 |
o1o111
|
9년 전 | 923 | |
| 8070 | 9년 전 | 431 | ||
| 8069 | 9년 전 | 369 | ||
| 8068 | 9년 전 | 618 | ||
| 8067 | 9년 전 | 420 | ||
| 8066 | 9년 전 | 444 | ||
| 8065 | 9년 전 | 406 | ||
| 8064 | 9년 전 | 400 | ||
| 8063 | 9년 전 | 367 | ||
| 8062 | 9년 전 | 338 | ||
| 8061 | 9년 전 | 373 | ||
| 8060 | 9년 전 | 417 | ||
| 8059 | 9년 전 | 352 | ||
| 8058 | 9년 전 | 291 | ||
| 8057 | 9년 전 | 417 | ||
| 8056 | 9년 전 | 335 | ||
| 8055 | 9년 전 | 383 | ||
| 8054 | 9년 전 | 387 | ||
| 8053 | 9년 전 | 439 | ||
| 8052 | 9년 전 | 310 | ||
| 8051 | 9년 전 | 358 | ||
| 8050 | 9년 전 | 413 | ||
| 8049 | 9년 전 | 349 | ||
| 8048 | 9년 전 | 452 | ||
| 8047 | 9년 전 | 392 | ||
| 8046 | 9년 전 | 336 | ||
| 8045 | 9년 전 | 284 | ||
| 8044 | 9년 전 | 373 | ||
| 8043 | 9년 전 | 331 | ||
| 8042 | 9년 전 | 317 | ||
| 8041 | 9년 전 | 381 | ||
| 8040 | 9년 전 | 300 | ||
| 8039 | 9년 전 | 344 | ||
| 8038 | 9년 전 | 284 | ||
| 8037 | 9년 전 | 430 | ||
| 8036 | 9년 전 | 518 | ||
| 8035 | 9년 전 | 451 | ||
| 8034 | 9년 전 | 410 | ||
| 8033 | 9년 전 | 371 | ||
| 8032 | 9년 전 | 475 | ||
| 8031 | 9년 전 | 366 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기