|
|
|
calendar ปฏิทินครับ รันไม่ขึ้น รบกวนดูให้หน่อยครับ |
|
|
|
|
|
|
|
Code (ASP)
<%Response.Write(GenerateCalendar)%>
<style type="text/css">
body {
font-family:Arial, Helvetica, sans-serif;
font-size:small;
background-color:#EEFFFF;
color:#000099;
}
table {
background-color:#FFFFFF;
border: #000000 1px solid;
}
td, th {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: x-small;
text-align: center;
color: #000066;
border: #000000 1px solid;
} .smalltext {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: x-small;
text-align: left;
color: #006600;
} td.today {
color: #FF0000;
font-weight: bold;
}
th {
font-weight: bold;
}
h2 {
display: inline;
font-size: medium
font-weight; bold
}
</style>
<%
Dim arrMonth(11)
Dim iMonth, iYear, i
' get month number (if first time, then use current month)
If Len(Request.QueryString("m")) = 0 Then
iMonth = Month(Now)
Else
iMonth = CInt(Request.QueryString("m"))
End If
' get year
If Len(Request.QueryString("y")) = 0 Then
iYear = Year(Now)
Else
iYear = CInt(Request.QueryString("y"))
End If
' check for leap year
If (iYear Mod 4) = 0 And (iYear Mod 100) <> 0 Or (iYear Mod 400) = 0 Then
' update febuary to leap year
arrDayCount(1) = "29"
End If
' month names
For i = 0 To 11
arrMonth(i) = MonthName(i + 1)
Next 'i
Function GenerateCalendar()
Dim sMonth, sLeap
Dim sStartGaps, sEndGaps
Dim sPrevious, sNext
Dim sCalendar
Dim arrDayCount, arrDaysOfWeek
Dim i, j, iDay, iStartDay, iDayCount
' days in each month
arrDayCount = Split("31,28,31,30,31,30,31,31,30,31,30,31", ",")
' days of the week
arrDaysOfWeek = Split("Sun,Mon,Tue,Wed,Thu,Fri,Sat", ",")
' get day
If Len(Request.QueryString("d")) = 0 Then
iDay = Day(Now)
Else
iDay = CInt(Request.QueryString("d"))
End If
' get month start day
iStartDay = WeekDay("01/" & iMonth & "/" & iYear)
' set start "gaps"
sStartGaps = Replace(Space(iStartDay - 1), " ", "<td></td>" )
' write table header
sCalendar = "<table><colgroup><col span=""7"" width=""14%"" /></colgroup>"
sCalendar = sCalendar & "<tr><td colspan=""7""><h2>" & arrMonth(iMonth - 1) & " " & iYear & "</h2></td></tr>"
sCalendar = sCalendar & "<tr>"
For i = 0 To 6
sCalendar = sCalendar & "<th>" & arrDaysOfWeek(i) & "</th>"
Next ' i
sCalendar = sCalendar & "</tr>"
' write table content
' first row
sCalendar = sCalendar & "<tr>"
sCalendar = sCalendar & sStartGaps
For i = 1 To (8 - iStartDay)
sCalendar = sCalendar & "<td>" & i & "</td>"
Next ' i
sCalendar = sCalendar & "</tr>"
' whole rows
iDayCount = i
For j = 1 To Int(CInt(arrDayCount(iMonth - 1)) / 7) - 1
sCalendar = sCalendar & "<tr>"
For i = 1 To 7
sCalendar = sCalendar & "<td>" & iDayCount & "</td>"
iDayCount = iDayCount + 1
Next ' i
sCalendar = sCalendar & "</tr>" Next ' j
' last row
sCalendar = sCalendar & "<tr>"
For i = iDayCount To CInt(arrDayCount(iMonth - 1))
If i - iDayCount = 7 Then sCalendar = sCalendar & "</tr><tr>"
sCalendar = sCalendar & "<td>" & i & "</td>"
Next ' i
sCalendar = sCalendar & "</tr>"
' get previous month
If iMonth - 1 = 0 Then
sPrevious = "?m=12&y=" & iYear - 1
Else
sPrevious = "?m=" & iMonth - 1 & "&y=" & iYear
End If
' get next month
If iMonth + 1 = 13 Then
sNext = "?m=1&y=" & iYear + 1
Else
sNext = "?m=" & iMonth + 1 & "&y=" & iYear
End If
sCalendar = sCalendar & "<tr><td colspan=""7""><a href='" & sPrevious & "' title='view previous month'>previous</a> | <a href='" & sNext & "' title='view next month'>next</a></td></tr>"
sCalendar = sCalendar & "</table>"
' highlight current day (if applicable)
If Year(Now) = iYear And Month(Now) = iMonth Then
sCalendar = Replace(sCalendar, "<td>" & iDay & "</td>", "<td class=""today"" title=""today"">" & iDay & "</td>")
End If
sCalendar = sCalendar & "<p class=""smalltext"">ASP calendar ©" & Year(Now) & " xposition</p>"
GenerateCalendar = sCalendar ' return calendar html
End Function
%>
หาโค้ดมาจากเว็บครับ
ลองรันดูไม่ขึ้น ผิดตรงไหนครับ?
Tag : ASP, Ms Access, HTML/CSS, Ajax, jQuery, Web (ASP.NET)
|
|
|
|
|
|
Date :
2016-11-24 18:15:31 |
By :
tongarn |
View :
1255 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มี Error หรือเปล่าครับ
|
|
|
|
|
Date :
2016-11-25 09:22:23 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|