¾Æ·¡´Â º» ½ºÅ©¸³Æ®ÀÇ ¼Ò½ºÀÔ´Ï´Ù.
<!-- Javascript Calendar by SWLee, http://swlee99.tistory.com, sunmind99 @ hotmail . com//--> <SCRIPT LANGUAGE="JavaScript"> // ´Þ·ÂÀÇ ÇÁ·¹ÀÓ document.write("<DIV ID='SimpleCalendar' STYLE='position:absolute; z-index:90'></DIV>"); document.write("<DIV ID='ToolTip' STYLE='position:absolute; z-index:99'></DIV>");
// ÇØ´ç ÀÏÀÇ ¿äÀÏÀ» ±¸ÇÏ´Â ÇÔ¼ö, 1³â 1¿ù 1ÀϺÎÅÍ °è»ê var MonthsDay = new Array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) var WeekDays = new Array("ÀÏ", "¿ù", "È", "¼ö", "¸ñ", "±Ý", "Åä"); var IsCalendarVisible = 0;
// ÅøÆÁ ¼³¸í °ü·Ã ÇÔ¼ö function ShowToolTip(option) { document.all.ToolTip.style.left = event.clientX; document.all.ToolTip.style.top = event.clientY + 15; document.all.ToolTip.style.visibility = 'visible'; ToolTipHTML = "<TABLE BGCOLOR='#ffffff' BORDER=1 CELLPSPACING=0 CELLPADDING=2 BORDERCOLOR='#000000'><TR>"; ToolTipHTML += "<TD BGCOLOR='#ff0000' STYLE='border:0'>"; ToolTipHTML += "<FONT FACE='µ¸¿ò' SIZE='2' COLOR='#ffffff'><B>"; if(option == 1) { ToolTipHTML += "Àü³âµµ·Î"; } if(option == 2) { ToolTipHTML += "Àü´Þ·Î"; } if(option == 3) { ToolTipHTML += "´ÙÀ½´Þ·Î"; } if(option == 4) { ToolTipHTML += "´ÙÀ½ÇØ·Î"; } ToolTipHTML += "</FONT></B></TD></TR>"; document.all.ToolTip.innerHTML = ToolTipHTML; }
// ÅøÆÁ °ü·Ã À̵¿ ÇÔ¼ö function MoveToolTip(option) { document.all.ToolTip.style.left = event.clientX; document.all.ToolTip.style.top = event.clientY + 15; }
// ÅøÆÁ ¼û±è ÇÔ¼ö function HideToolTip(option) { document.all.ToolTip.style.visibility = 'hidden'; }
function GetWeekday(Year, Month, Day) { var TotalDays = Year * 365; // 0³â 1¿ù 1ÀϺÎÅÍÀÇ ÃÑÀϼö var LeafYears = Year / 4; // À±³âȽ¼ö var CurrentYearDays = eval(Day); // ¿ÃÇØ¿¡¼ Áö³ ³¯Â¥ for(i = 0; i < Month; i++) { CurrentYearDays += MonthsDay[i]; } if(LeafYears < eval(LeafYears.toFixed(0))) { LeafYears = LeafYears - 1; }
TotalDays = TotalDays + CurrentYearDays + eval(LeafYears.toFixed(0));
// 0³â 1¿ù 1ÀÏÀÌ Åä¿äÀÏÀ̹ǷΠ6À» ´õÇÔ var RemainDays = (TotalDays + 6) % 7;
return RemainDays; }
function SetObjectDate(InputObject, Year, Month, Day) { InputObject.value = Year + "-" + Month + "-" + Day; }
function SetDayColor(Object) { Object.style.backgroundColor = '#aaffaa'; }
function RemoveDayColor(Object) { Object.style.backgroundColor = ''; }
function InnerOpenCalendar(InputObject, Year, Month, Day, VisibleChange) { var DayIndex = 1; var i = 0; var CalendarYear = 0;
var TempYear = 0; var TempMonth = 0;
if(!SimpleCalendar.style.pixelTop) { SimpleCalendar.style.pixelTop = event.clientY + 15; SimpleCalendar.style.pixelLeft = event.clientX - 100; }
if((IsCalendarVisible == 0) && (VisibleChange == 1)) { document.all.SimpleCalendar.style.visibility = "visible"; IsCalendarVisible = 1; } else { if(VisibleChange == 1) { document.all.SimpleCalendar.style.visibility = "hidden"; IsCalendarVisible = 0; } }
CalendarHTML = "<TABLE STYLE='border-style:single' BORDER='1' BGCOLOR='#ffffff' CELLPADDING='1' CELLSPACING='0' BORDERCOLOR='#000000' WIDTH='220'>"; CalendarHTML += "<TR>";
CalendarHTML += "<TD BGCOLOR='#ccccff' COLSPAN=7>";
// ¹Ù·Î Àü³âµµ·Î °¡´Â ¹öÆ° Ãâ·Â TempYear = eval(Year) - 1; CalendarHTML += "<A STYLE='cursor:hand' ONMOUSEOVER='JavaScript:ShowToolTip(1)' ONMOUSEMOVE='JavaScript:MoveToolTip()' ONMOUSEOUT='JavaScript:HideToolTip()' "; CalendarHTML += "ONCLICK='JavaScript:InnerOpenCalendar(document.all." + InputObject.name + ", " + TempYear + ", " + Month + ", " + Day + ", 0)'>"; CalendarHTML += "<FONT SIZE='2' FACE='µ¸¿ò' COLOR='#7777ff'>¢¸¢¸</FONT></A> ";
// ¹Ù·Î ¾Õ´Þ·Î °¡´Â ¹öÆ° Ãâ·Â TempMonth = eval(Month) - 1; if(TempMonth == 0) { TempYear = eval(Year) - 1; TempMonth = 12; } else { TempYear = eval(Year); } CalendarHTML += "<A STYLE='cursor:hand' ONMOUSEOVER='JavaScript:ShowToolTip(2)' ONMOUSEMOVE='JavaScript:MoveToolTip()' ONMOUSEOUT='JavaScript:HideToolTip()' "; CalendarHTML += "ONCLICK='JavaScript:InnerOpenCalendar(document.all." + InputObject.name + ", " + TempYear + ", " + TempMonth + ", " + Day + ", 0)'>"; CalendarHTML += "<FONT SIZE='2' FACE='µ¸¿ò' COLOR='#7777ff'>¢¸</FONT></A>";
// ¿¬µµ ¼±Åà Ãâ·Â CalendarHTML += "<SELECT NAME='CalendarYear' "; CalendarHTML += "ONCHANGE='JavaScript:InnerOpenCalendar(document.all." + InputObject.name + ", this.value, " + Month + ", " + Day + ", 0)'>"; for(i = -10; i <= 10; i++) { CalendarYear = eval(Year) + i; if(CalendarYear == eval(Year)) { CalendarHTML += "<OPTION VALUE='" + eval(Year) + eval(i) + "' SELECTED> " + CalendarYear + "</OPTION>"; } else { CalendarHTML += "<OPTION VALUE='" + eval(Year) + eval(i) + "'>"; CalendarHTML += CalendarYear + "</OPTION>"; } } CalendarHTML += "</SELECT><FONT SIZE='2'><B>³â </B></FONT>"; // ¿¬µµ ¼±Åà Ãâ·Â ³¡ // ´Þ Ãâ·Â CalendarHTML += "<SELECT NAME='CalendarMonth' "; CalendarHTML += "ONCHANGE='JavaScript:InnerOpenCalendar(document.all." + InputObject.name + ", " + Year + ", this.value, " + Day + ", 0)'>"; for(i = 1; i <= 12; i++) { if(i == eval(Month)) { CalendarHTML += "<OPTION VALUE='" + i + "' SELECTED> " + i + "</OPTION>"; } else { CalendarHTML += "<OPTION VALUE='" + i + "'> " + i + "</OPTION>"; } } CalendarHTML += "</SELECT><FONT SIZE='2'><B>¿ù</B></FONT>"; // ´Þ Ãâ·Â ³¡
// ¹Ù·Î ´ÙÀ½´Þ·Î °¡´Â ¹öÆ° Ãâ·Â TempMonth = eval(Month) + 1; if(TempMonth == 13) { TempYear = eval(Year) + 1; TempMonth = 1; } else { TempYear = eval(Year); } CalendarHTML += "<A STYLE='cursor:hand' ONMOUSEOVER='JavaScript:ShowToolTip(3)' ONMOUSEMOVE='JavaScript:MoveToolTip()' ONMOUSEOUT='JavaScript:HideToolTip()' "; CalendarHTML += "ONCLICK='JavaScript:InnerOpenCalendar(document.all." + InputObject.name + ", " + TempYear + ", " + TempMonth + ", " + Day + ", 0)'>"; CalendarHTML += "<FONT SIZE='2' FACE='µ¸¿ò' COLOR='#7777ff'>¢º</FONT></A> ";
// ¹Ù·Î ´ÙÀ½³âµµ·Î °¡´Â ¹öÆ° Ãâ·Â TempYear = eval(Year) + 1; CalendarHTML += "<A STYLE='cursor:hand' ONMOUSEOVER='JavaScript:ShowToolTip(4)' ONMOUSEMOVE='JavaScript:MoveToolTip()' ONMOUSEOUT='JavaScript:HideToolTip()' "; CalendarHTML += "ONCLICK='JavaScript:InnerOpenCalendar(document.all." + InputObject.name + ", " + TempYear + ", " + Month + ", " + Day + ", 0)'>"; CalendarHTML += "<FONT SIZE='2' FACE='µ¸¿ò' COLOR='#7777ff'>¢º¢º</FONT></A> ";
CalendarHTML += "</TD></TR>"; // HTML ¿äÀÏ Ãâ·Â for(i = 0; i < 7; i++) { CalendarHTML += "<TD BGCOLOR='2222ff' STYLE='border:0' ALIGN='center'><FONT SIZE='2' FACE='µ¸¿ò' COLOR='#ffffff'><B>" + WeekDays[i] + "</B></TD>"; } // ½ÃÀÛÀÏÀÇ ¿äÀÏÀ» ±¸ÇÏ°í.. (Åä¿äÀÏÀº 7¿äÀÏÀÌ µÊ) // 1:ÀÏ¿äÀÏ 2:¿ù¿äÀÏ ... 7:Åä¿äÀÏ var StartWeekday = GetWeekday(Year, Month, '1'); if(StartWeekday == 0) { StartWeekday = 7; }
// ±× Àϼö¸¸Å ºó ÅÂ±× »ðÀÔ CalendarHTML += "<TR>"; for(i = 1; i < StartWeekday; i++) { CalendarHTML += "<TD></TD>"; DayIndex = DayIndex + 1; }
// ÀÌÁ¦ ÇØ´ç ¿ùÀÇ ³¯Â¥ Ãâ·Â.. for(i = 1; i <= MonthsDay[Month]; i++) { CalendarHTML += "<TD STYLE='cursor:hand' STYLE='border:0' ALIGN='center' "; CalendarHTML += "ONCLICK='JavaScript:SetObjectDate(document.all." + InputObject.name + ", " + Year + ", " + Month + ", " + i + ")' "; CalendarHTML += " ONMOUSEOVER='JavaScript:SetDayColor(this, i)' ONMOUSEOUT='JavaScript:RemoveDayColor(this, i)'>"; CalendarHTML += "<FONT ID=' " + i + "font' SIZE='2' FACE='µ¸¿ò'>" + i + "</FONT></TD>"; if((DayIndex % 7) == 0) { CalendarHTML += "</TR>"; CalendarHTML += "<TR>"; } DayIndex = DayIndex + 1; }
CalendarHTML += "</TR>"; CalendarHTML += "</TABLE>";
document.all.SimpleCalendar.innerHTML = CalendarHTML; }
function OpenCalendar(InputObject, Year, Month, Day) { var TodayDate = new Date(); if(Year == 0) { Year = TodayDate.getYear(); } if(Month == 0) { Month = TodayDate.getMonth() + 1; } if(Day == 0) { Day = TodayDate.getDate(); } InnerOpenCalendar(InputObject, Year, Month, Day, 1); } </SCRIPT>
<BODY> <INPUT NAME="InputDate" TYPE="text" /> <A ONCLICK="OpenCalendar(InputDate, 2007, 12, 14)" STYLE="cursor:hand">´Þ·Â º¸±â</A> </BODY> </HTML>
|