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에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7430 |
|
11년 전 | 4947 | |
| 7429 | 11년 전 | 1780 | ||
| 7428 |
멋진남자임
|
11년 전 | 1174 | |
| 7427 |
sdflksdj2
|
11년 전 | 832 | |
| 7426 | 11년 전 | 1366 | ||
| 7425 | 11년 전 | 1393 | ||
| 7424 | 11년 전 | 1054 | ||
| 7423 |
SeungYeon
|
11년 전 | 565 | |
| 7422 | 11년 전 | 812 | ||
| 7421 |
sdflksdj2
|
11년 전 | 691 | |
| 7420 | 11년 전 | 974 | ||
| 7419 |
|
11년 전 | 1406 | |
| 7418 |
멋진남자임
|
11년 전 | 1445 | |
| 7417 | 11년 전 | 609 | ||
| 7416 |
senseme
|
11년 전 | 1236 | |
| 7415 | 11년 전 | 965 | ||
| 7414 | 11년 전 | 715 | ||
| 7413 | 11년 전 | 4852 | ||
| 7412 | 11년 전 | 4408 | ||
| 7411 |
holla
|
11년 전 | 899 | |
| 7410 | 11년 전 | 4255 | ||
| 7409 | 11년 전 | 3930 | ||
| 7408 | 11년 전 | 4273 | ||
| 7407 | 11년 전 | 5092 | ||
| 7406 | 11년 전 | 4737 | ||
| 7405 | 11년 전 | 4305 | ||
| 7404 | 11년 전 | 766 | ||
| 7403 | 11년 전 | 5685 | ||
| 7402 | 11년 전 | 1524 | ||
| 7401 |
|
11년 전 | 980 | |
| 7400 | 11년 전 | 2977 | ||
| 7399 |
멋진남자임
|
11년 전 | 924 | |
| 7398 |
파랑새1597
|
11년 전 | 2713 | |
| 7397 | 11년 전 | 2279 | ||
| 7396 |
basketball
|
11년 전 | 1379 | |
| 7395 | 11년 전 | 1618 | ||
| 7394 | 11년 전 | 936 | ||
| 7393 | 11년 전 | 2076 | ||
| 7392 | 11년 전 | 852 | ||
| 7391 |
잘살아보자
|
11년 전 | 5366 | |
| 7390 |
잘살아보자
|
11년 전 | 2231 | |
| 7389 |
잘살아보자
|
11년 전 | 3324 | |
| 7388 |
파랑새1597
|
11년 전 | 932 | |
| 7387 | 11년 전 | 1109 | ||
| 7386 |
프리랜서퍼블리셔
|
11년 전 | 974 | |
| 7385 | 11년 전 | 1574 | ||
| 7384 |
울라라라우
|
11년 전 | 894 | |
| 7383 | 11년 전 | 1559 | ||
| 7382 |
잘살아보자
|
11년 전 | 4231 | |
| 7381 |
잘살아보자
|
11년 전 | 2004 | |
| 7380 |
잘살아보자
|
11년 전 | 1947 | |
| 7379 |
잘살아보자
|
11년 전 | 5912 | |
| 7378 |
senseme
|
11년 전 | 1904 | |
| 7377 |
잘살아보자
|
11년 전 | 2754 | |
| 7376 | 11년 전 | 2422 | ||
| 7375 |
잘살아보자
|
11년 전 | 1055 | |
| 7374 |
잘살아보자
|
11년 전 | 3166 | |
| 7373 |
잘살아보자
|
11년 전 | 2484 | |
| 7372 |
잘살아보자
|
11년 전 | 5834 | |
| 7371 |
잘살아보자
|
11년 전 | 3472 | |
| 7370 |
잘살아보자
|
11년 전 | 1917 | |
| 7369 |
잘살아보자
|
11년 전 | 2176 | |
| 7368 |
ksdhtm56
|
11년 전 | 575 | |
| 7367 | 11년 전 | 1440 | ||
| 7366 | 11년 전 | 941 | ||
| 7365 | 11년 전 | 3552 | ||
| 7364 |
잘살아보자
|
11년 전 | 1404 | |
| 7363 |
잘살아보자
|
11년 전 | 1377 | |
| 7362 |
잘살아보자
|
11년 전 | 1517 | |
| 7361 | 11년 전 | 3603 | ||
| 7360 | 11년 전 | 3568 | ||
| 7359 | 11년 전 | 3387 | ||
| 7358 |
멋진남자임
|
11년 전 | 1038 | |
| 7357 | 11년 전 | 3422 | ||
| 7356 | 11년 전 | 2609 | ||
| 7355 | 11년 전 | 3201 | ||
| 7354 |
파랑새1597
|
11년 전 | 655 | |
| 7353 |
잘살아보자
|
11년 전 | 2432 | |
| 7352 |
잘살아보자
|
11년 전 | 2424 | |
| 7351 |
잘살아보자
|
11년 전 | 2485 | |
| 7350 |
잘살아보자
|
11년 전 | 1480 | |
| 7349 |
잘살아보자
|
11년 전 | 1972 | |
| 7348 |
잘살아보자
|
11년 전 | 1289 | |
| 7347 |
잘살아보자
|
11년 전 | 1084 | |
| 7346 |
멋진남자임
|
11년 전 | 1653 | |
| 7345 | 11년 전 | 1001 | ||
| 7344 | 11년 전 | 3882 | ||
| 7343 | 11년 전 | 3666 | ||
| 7342 | 11년 전 | 1291 | ||
| 7341 | 11년 전 | 2531 | ||
| 7340 |
|
11년 전 | 943 | |
| 7339 | 11년 전 | 1740 | ||
| 7338 | 11년 전 | 3355 | ||
| 7337 | 11년 전 | 3667 | ||
| 7336 | 11년 전 | 4608 | ||
| 7335 | 11년 전 | 983 | ||
| 7334 | 11년 전 | 1540 | ||
| 7333 | 11년 전 | 2946 | ||
| 7332 |
|
11년 전 | 1117 | |
| 7331 |
KeePin뽁이
|
11년 전 | 1108 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기