webForumDet fria alternativet

C Calendar 0.8

ASP

6 svar · 214 visningar · startad av cherub

Medlem sedan apr. 200171 inlägg
Frågan#1

Det stod i reglerna när man skickade in script att man skulle skapa en tråd runt det. Så här kommer den. Tråden gäller scriptet:

http://script.webforum.nu/wf/Forum1/HTML/000061.html

------------------
- Rickard
http://cherub.deca-production.net
"You say I'm beautiful. Well, I can't help it! You say I'm empty. We all know I'm full of shit!"

[Redigerat av cherub den 20 apr 2001]

Medlem sedan juli 2000619 inlägg
#2

Jag tror det är en bugg i kalendern.. skottår visas inte korrekt.. blir iaf. 28 dagar i februrari trots skottår.

------------------
Ingenting är omöjligt, bara en utmaning.

Medlem sedan apr. 200171 inlägg
#3

det har du rätt i... ;-) har fixat det nu.. så laddar du ner den igen är det fixat...

------------------
- Rickard
http://cherub.deca-production.net
"You say I'm beautiful. Well, I can't help it! You say I'm empty. We all know I'm full of shit!"

Medlem sedan jan. 20011 140 inlägg
#4

Var ska jag ändra i koden så att varje dag blir länkad till en ny sida?

Medlem sedan apr. 200171 inlägg
#5

Har inte scriptet här ju nu... Fick en HD-crash.... Men raden
Response.Write iDay
Är den rad som skriver ut datumet...
Så där får du ändra... hur du vill ha det...

------------------
- Rickard
http://cherub.deca-production.net
"You say I'm beautiful. Well, I can't help it! You say I'm empty. We all know I'm full of shit!"

Medlem sedan dec. 1999653 inlägg
#6

för er som e nyfikna så har jag mixat lite med kalendern å får allt å funka med databas å så nu iaf :)

här kommer koden som ni ska ersätta Response.Write iDay med.
först måste ni naturligtvis ha en databaskoppling:

Dim provider, ConnectionString, cn, rs, SQL
Set cn = Server.CreateObject("ADODB.Connection")
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & Server.MapPath("events.mdb")
.Open
End With

den lägger ni förslagsvis högst upp i filen. databasen jag har nu heter events med tabellen dagbok som är uppbygd såhär:
year | Number
month | Number
day | Number
dagbok | Memo

sen kommer vi till själva koden då datumet skall göras till en länk, denna kan se ut som detta:

SQL = "SELECT * FROM dagbok WHERE [year] = "& iYear_ &" AND [month] = "& iMonth_ &" AND [day] = "& iDay
Set rs = cn.Execute(SQL)

If rs.EOF Then
Response.Write iDay
Else
Response.Write "<a href='dagbok.asp?ar="& iYear_ &"&man="& iMonth_ &"&day="& iDay &"'>"& iDay &"</a>"
End If

ersätt alltså Response.Write iDay med koden ovan, så bör allt funka som ni vill. å glöm inte å ändra dagbok.asp till den sidan ni vill.. :)

mvh

------------------
void[]
stash/$gu&-public(querystring)/n int{}bind "2" "say i own!" :)

Medlem sedan maj 20011 343 inlägg
#7

varför får jag inte dagensdatum markerat?
Jag har ändrat koden så som nakoz skrev!

koden ser ut så här:


Dim provider, ConnectionString, cn, rs, SQL
Set cn = Server.CreateObject("ADODB.Connection")
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & Server.MapPath("events.mdb")
.Open
End With 

Class cCalendar

Private iMonth_				'** Current month 	&#0124; Default: This month
Private iYear_				'** Current year 	&#0124; Default: This year

	'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>&gt ;>>>>>>>>>>>>>>>
	'** Constructor
	'** Sets some values to default
	'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>&gt ;>>>>>>>>>>>>>>>
	Public Sub Class_Initialize()

		iYear_ = Year(date())
		iMonth_ = Month(date())

	End Sub
	
	'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>&gt ;>>>>>>>>>>>>>>>
	'** Returns the number of days in specified month
	'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>&gt ;>>>>>>>>>>>>>>>
	Private Function DaysInMonth()
	
	'** Declare Variables
		Dim iDaysInMonth
				
		Select Case iMonth_
			Case 1, 3, 5, 7, 8, 10, 12 	'** Months with 31 days
				iDaysInMonth = 31
			Case 4, 6, 9, 11 			'** Months with 30 days
				iDaysInMonth = 30 
			Case 2 						'** Check february if it's leap year or not
				If IsDate(iYear_ & "-02-29") Then
					iDaysInMonth = 29
				Else
					iDaysInMonth = 28
				End If
		End Select
		
	DaysInMonth = iDaysInMonth

	End Function
	
	'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>&gt ;>>>>>>>>>>>>>>>
	'** Returns the number of day that the first day in the month has
	'** 1 = Monday, 7 = Sunday
	'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>&gt ;>>>>>>>>>>>>>>>	
	Private Function StartWeekday()
	
		'** Weekday() returns by default 1 = Sunday and 7 = Saturday
		'** but we want Monday to be 1 and sunday to be 7
		'** there for this function.
		
		'** Declare Variables
			Dim dtMonthdate, iStartWeekday
		
		dtMonthdate = iYear_ & "-" & iMonth_ & "-01"	
		iStartWeekday = Weekday(dtMonthdate)
	
			If iStartWeekday > 1 Then 
				iStartWeekday = iStartWeekday - 1
			
			Else
				iStartWeekday = iStartWeekday + 6
			
			End If 
			
	StartWeekday = iStartWeekday
	
	End Function
	
	'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>&gt ;>>>>>>>>>>>>>>>
	'** Returns how many rows the calendar will contain
	'** One row = 7 days (Monday to Sunday)
	'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>&gt ;>>>>>>>>>>>>>>>
	Private Function TableRows(iDaysInMonth, iStartWeekday)
		Dim iBoxes, iTblRows
		
		iBoxes = (iDaysInMonth + (iStartWeekday - 1))
	
			If iBoxes = 28 Or iBoxes = 35 Or iBoxes = 42 Then
				iTblRows = iBoxes / 7

			ElseIf iBoxes > 28 And iBoxes < 35 Then
				iTblRows = 5

			Else
				iTblRows = 6

			End If
		
		TableRows = iTblRows
			
	End Function
	
	'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>&gt ;>>>>>>>>>>>>>>>
	'** Return values one month forward and backward
	'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>&gt ;>>>>>>>>>>>>>>>	
	Private Sub SetBackwardAndForwardValues (ByRef iMonthBackward, ByRef iMonthForward, _
											 ByRef iYearBackward, ByRef iYearForward)
		Select Case iMonth_
			Case 12
				iMonthForward = 1
				iMonthBackward = 11
				iYearForward = iYear_ + 1
				iYearBackward = iYear_
			Case 1
				iMonthForward = 2
				iMonthBackward = 12
				iYearForward = iYear_
				iYearBackward = iYear_ - 1
			Case Else
				iMonthForward = iMonth_ + 1
				iMonthBackward = iMonth_ - 1
				iYearForward = iYear_
				iYearBackward = iYear_
		End Select
						
	End Sub	
	
	'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>&gt ;>>>>>>>>>>>>>>>
	'** Draw the calendar
	'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>&gt ;>>>>>>>>>>>>>>>
	Public Sub GetCalendar(iMonth, iYear, sThisPage, sBorderColor)
	
	'** GetValues
		If Not iMonth = "" Then iMonth_ = iMonth 	'** Get Month
		If Not iYear = "" Then iYear_ = iYear 		'** Get Year
	
		

		'** Table for calendar
			Response.Write "<table cellspacing=""0"" cellpadding=""0"" border=""0"" width=""25%"">"
			
			'** First row
				Response.Write "<tr>"
				    Response.Write "<td height=""3"" colspan=""15"" bgcolor=""" & sBorderColor & """><img src=""1x1.gif"" width=""1"" height=""1"" border=""0""></td>"
				Response.Write "</tr>"
				
				Response.Write "<tr>"
					Response.Write "<td width=""3"" bgcolor=""" & sBorderColor & """><img src=""1x1.gif"" width=""1"" height=""1"" border=""0""></td>"
				    Response.Write "<td colspan=""13"">"
					
					'** HEAD: Displays month and year + arrows that allows you to go backward and forward
						Response.Write "<table cellspacing=""0"" cellpadding=""0"" border=""0"" width=""100%"">"
							Response.Write "<tr>"
								Response.Write "<td width=""75%"" align=""left"" class=""Size11Blue"">"
									
								'** Declare variables
									Dim sMonthName
									
								'** The MonthName() function returns the name in lowercase and we want the first letter to be uppercase
									sMonthName = UCase(Left(MonthName(iMonth_),1)) & Right(MonthName(iMonth_),Len(MonthName(iMonth_))-1) 
									Response.Write sMonthName & ", " & iYear_
								
								Response.Write "</td>"
								
							'** Declare variables
								Dim iMonthForward, iMonthBackward, iYearForward, iYearBackward
							
							'** Return values one month forward and backward
								Call SetBackwardAndForwardValues (iMonthBackward, iMonthForward, iYearBackward, iYearForward)
	
								Response.Write "<td width=""25%"" align=""center"">"
									
									'** Arrows that allows you to go backward and forward
										Response.Write "<a href=""" & sThisPage & "?iMonth=" & iMonthBackward & "&iYear=" & iYearBackward & """><img src=""arrow_left.gif"" width=""10"" height=""10"" border=""0""></a>"
										Response.Write "&nbsp;&nbsp;"
										Response.Write "<a href=""" & sThisPage & "?iMonth=" & iMonthForward & "&iYear=" & iYearForward & """><img src=""arrow_right.gif"" width=""10"" height=""10"" border=""0""></a>"
										
								Response.Write "</td>"
							Response.Write "</tr>"
						Response.Write "</table>"
					'** END HEAD
				
					Response.Write "</td>"
					Response.Write "<td width=""3"" bgcolor=""" & sBorderColor & """><img src=""1x1.gif"" width=""1"" height=""1"" border=""0""></td>"
				Response.Write "</tr>"
									
				Response.Write "<tr>"
				    Response.Write "<td height=""3"" colspan=""15"" bgcolor=""" & sBorderColor & """><img src=""1x1.gif"" width=""1"" height=""1"" border=""0""></td>"
				Response.Write "</tr>"
				
			'** Displays the days to the calendar Monday - Sunday
				Response.Write "<tr>"
					
					Response.Write "<td width=""3"" bgcolor=""" & sBorderColor & """><img src=""1x1.gif"" width=""1"" height=""1"" border=""0""></td>"
				
				'** Declare variables
					Dim i, sWeekdayName
				
				'** Loop for each day in a week Monday - Sunday
					For i = 1 to 7
						
						'** WeekdayName() returns the name in lowercase. We want the first letter to be uppercase and the rest lowercase
						sWeekdayName = Ucase(Left(WeekdayName(i, True, 2), 1)) & Right(WeekdayName(i, True, 2), Len(WeekdayName(i, True, 2)) - 1)
						
						Response.Write "<td align=""center"" valign=""center"" class=""Size11DarkGray"">" & sWeekdayName & "</td>"
						Response.Write "<td width=""3"" bgcolor=""" & sBorderColor & """><img src=""1x1.gif"" width=""1"" height=""1"" border=""0""></td>"								
		
					Next
					
				Response.Write "</tr>"
		
				Response.Write "<tr>"
				    Response.Write "<td height=""3"" colspan=""15"" bgcolor=""" & sBorderColor & """><img src=""1x1.gif"" width=""1"" height=""1"" border=""0""></td>"
				Response.Write "</tr>"
				
			'** Declare variables
				Dim iCount, iDay, iDaycount, iDaysInMonth, iStartWeekday, iTableRows
				Dim bFirstrow
				
			'** Set values
				iDaysInMonth = DaysInMonth() 	'** Returns how many days there is in the current month
				iStartWeekday = StartWeekday()	'** Returns which day the month starts on (1-7)
				iTableRows = TableRows(iDaysInMonth, iStartWeekday) '** Returns how many rows the table will be
				
			'** Initialize
				iCount = 0 : iDay = 1 : bFirstRow = True
			
				Do While iTableRows > iCount '** This will go round
				
					Response.Write "<tr>" '** Start row
					
					For iDaycount = 1 to 7 '** Loop to make 7 squares for 1 row
							
							If iDaycount = 1 Then Response.Write "<td width=""3"" bgcolor=""" & sBorderColor & """><img src=""1x1.gif"" width=""1"" height=""1"" border=""0""></td>"
							
								If ((bFirstrow = True) And (iDaycount < iStartWeekday)) Or (iDay > iDaysInMonth) Then '** This day does not exist in the month. Could be mars and iDay is 34
		
									Response.Write "<td align=""center"" valign=""center""><img src=""1x1.gif"" width=""1"" height=""1"" border=""0""></td>"
							
								ElseIf (iDay <= iDaysInMonth) Then '** Is iDay a day that exists in this month
								
									Response.Write "<td align=""center"" valign=""center"" class=""Size11DarkGray"">"
								
									'** Display day number
										SQL = "SELECT * FROM events WHERE [year] = "& iYear_ &" AND [month] = "& iMonth_ &" AND [day] = "& iDay
										Set rs = cn.Execute(SQL)
										If rs.EOF Then
										Response.Write iDay
										Else
										Response.Write "<a href='dagbok.asp?ar="& iYear_ &"&man="& iMonth_ &"&day="& iDay &"'>"& iDay &"</a>"
										End If

								
									Response.Write "</td>"
				
								End If
						
							Response.Write "<td width=""3"" bgcolor=""" & sBorderColor & """><img src=""1x1.gif"" width=""1"" height=""1"" border=""0""></td>"							
		
						
						If Not ((bFirstrow = True) And (iDaycount < iStartWeekday)) Then 
							iDay = iDay + 1
						ElseIf (bFirstrow = True) And (iDaycount >= iStartWeekday) Then
							iDay = iDay + 1 '** Add one to iDay and check that Day for posts
						End If
						
					Next
						
					Response.Write "</tr>"
		
				'** Last row
					Response.Write "<tr>"
				    	Response.Write "<td height=""3"" colspan=""15"" bgcolor=""" & sBorderColor & """><img src=""1x1.gif"" width=""1"" height=""1"" border=""0""></td>"
					Response.Write "</tr>"
				
				bFirstrow = False
				iCount = iCount + 1 '** Add one to count and show next 7 days
		
				Loop
				
			Response.Write "</table>"

	End Sub
	
	'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>&gt ;>>>>>>>>>>>>>>>
	'** Destructor
	'** Clean up
	'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>&gt ;>>>>>>>>>>>>>>>
	Public Sub Class_Terminate()

	End Sub	

End Class

		
Dim objCalendar		
Set objCalendar = New cCalendar
	
	'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>&gt ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	'** Inputvalues
	'** => iMonth 		&#0124; Pics up the QueryString iMonth. If it's empty this will be month this day
	'** => iYear		&#0124; Pics up the QueryString iYear. If it's empty this will be the year this day
	'** => sThis Page	&#0124; What page to send to when pushing forward or backward button
	'** => sBorderColor &#0124; What color to be used on the border
	'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>&gt ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	
	objCalendar.GetCalendar Request.QueryString("iMonth"), Request.QueryString("iYear"), "/calendar/calendar.asp","#f5f5f5"

Set objCalendar = Nothing

------------------
verktygslådan

Ett gott trams förlänger
livet :e

271 ms totalt · 4 externa anrop · v20260731065814-full.e96017d9
125 ms — deklarationer (db)
0 ms — hämta statistik (cache)
141 ms — hämta tråd, inlägg och bilagor (db)
127 ms — ändringar (db)