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에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7530 | 10년 전 | 827 | ||
| 7529 |
파랑새1597
|
10년 전 | 1253 | |
| 7528 |
파랑새1597
|
10년 전 | 1335 | |
| 7527 |
integrity7
|
10년 전 | 1422 | |
| 7526 | 10년 전 | 2447 | ||
| 7525 |
다빈치코드777
|
10년 전 | 1126 | |
| 7524 | 10년 전 | 1596 | ||
| 7523 | 10년 전 | 986 | ||
| 7522 |
|
10년 전 | 1013 | |
| 7521 |
blackkil
|
10년 전 | 1899 | |
| 7520 | 10년 전 | 1315 | ||
| 7519 |
Gaumi
|
10년 전 | 1096 | |
| 7518 | 10년 전 | 1507 | ||
| 7517 | 10년 전 | 843 | ||
| 7516 | 10년 전 | 1314 | ||
| 7515 | 10년 전 | 1431 | ||
| 7514 |
|
10년 전 | 4501 | |
| 7513 |
멋진남자임
|
10년 전 | 1143 | |
| 7512 |
다빈치코드777
|
10년 전 | 901 | |
| 7511 |
|
10년 전 | 3418 | |
| 7510 | 10년 전 | 1386 | ||
| 7509 | 10년 전 | 1164 | ||
| 7508 | 10년 전 | 731 | ||
| 7507 |
senseme
|
10년 전 | 775 | |
| 7506 |
멋진남자임
|
10년 전 | 1668 | |
| 7505 | 10년 전 | 4050 | ||
| 7504 | 10년 전 | 2176 | ||
| 7503 | 10년 전 | 1010 | ||
| 7502 | 10년 전 | 535 | ||
| 7501 | 10년 전 | 1463 | ||
| 7500 | 10년 전 | 1510 | ||
| 7499 | 10년 전 | 3418 | ||
| 7498 | 10년 전 | 1265 | ||
| 7497 |
dethos79
|
10년 전 | 2985 | |
| 7496 | 10년 전 | 2202 | ||
| 7495 | 10년 전 | 927 | ||
| 7494 |
CHAVO
|
10년 전 | 1160 | |
| 7493 | 10년 전 | 2675 | ||
| 7492 | 10년 전 | 1306 | ||
| 7491 | 10년 전 | 1518 | ||
| 7490 | 10년 전 | 2365 | ||
| 7489 | 10년 전 | 2135 | ||
| 7488 |
toptopon
|
10년 전 | 918 | |
| 7487 |
|
10년 전 | 1062 | |
| 7486 | 10년 전 | 3379 | ||
| 7485 | 10년 전 | 1332 | ||
| 7484 | 10년 전 | 1388 | ||
| 7483 | 10년 전 | 1045 | ||
| 7482 | 10년 전 | 677 | ||
| 7481 | 10년 전 | 871 | ||
| 7480 | 10년 전 | 1252 | ||
| 7479 | 10년 전 | 2625 | ||
| 7478 | 10년 전 | 1190 | ||
| 7477 |
멋진남자임
|
10년 전 | 1538 | |
| 7476 |
zeppeto
|
10년 전 | 1151 | |
| 7475 |
200점아빠
|
10년 전 | 935 | |
| 7474 | 10년 전 | 4021 | ||
| 7473 | 10년 전 | 1010 | ||
| 7472 |
나르시스1
|
10년 전 | 1261 | |
| 7471 | 10년 전 | 889 | ||
| 7470 | 10년 전 | 1310 | ||
| 7469 |
플라이SINJI
|
10년 전 | 1021 | |
| 7468 |
|
10년 전 | 581 | |
| 7467 |
|
10년 전 | 705 | |
| 7466 | 10년 전 | 1153 | ||
| 7465 | 10년 전 | 1204 | ||
| 7464 |
|
10년 전 | 1219 | |
| 7463 | 10년 전 | 1280 | ||
| 7462 |
진짜별사탕
|
10년 전 | 882 | |
| 7461 | 10년 전 | 968 | ||
| 7460 | 10년 전 | 3765 | ||
| 7459 |
멋진남자임
|
10년 전 | 1580 | |
| 7458 |
멋진남자임
|
10년 전 | 509 | |
| 7457 | 10년 전 | 936 | ||
| 7456 | 10년 전 | 784 | ||
| 7455 | 11년 전 | 2197 | ||
| 7454 | 11년 전 | 646 | ||
| 7453 | 11년 전 | 856 | ||
| 7452 |
중국어사이트제작
|
11년 전 | 521 | |
| 7451 | 11년 전 | 928 | ||
| 7450 | 11년 전 | 649 | ||
| 7449 |
울라라라우
|
11년 전 | 968 | |
| 7448 | 11년 전 | 1642 | ||
| 7447 |
멋진남자임
|
11년 전 | 528 | |
| 7446 | 11년 전 | 576 | ||
| 7445 |
네이비칼라
|
11년 전 | 1712 | |
| 7444 |
senseme
|
11년 전 | 1427 | |
| 7443 | 11년 전 | 1357 | ||
| 7442 | 11년 전 | 749 | ||
| 7441 |
멋진남자임
|
11년 전 | 1461 | |
| 7440 | 11년 전 | 932 | ||
| 7439 |
|
11년 전 | 787 | |
| 7438 |
|
11년 전 | 957 | |
| 7437 |
basement
|
11년 전 | 1054 | |
| 7436 |
잘살아보자
|
11년 전 | 1148 | |
| 7435 | 11년 전 | 1108 | ||
| 7434 | 11년 전 | 3802 | ||
| 7433 |
|
11년 전 | 2778 | |
| 7432 |
alexkim
|
11년 전 | 881 | |
| 7431 |
이웃집초보
|
11년 전 | 1328 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기