Avatar billede aero Nybegynder
07. december 2005 - 18:49 Der er 17 kommentarer og
1 løsning

Kalender med lidt fejl

Hej jeg har prøvet a lave en kalender
http://www.aeronet.dk/calendar/calendar.asp

Den vriker med at finde ud af hvor mange dag der er i en mdr og går fint frem og tilbage i mdr.
men:
1. Den stiller ikke datoerne rigtigt op hvis man kigger på den så mener den at den 1. i mdr er en søndag altid.

2. Mdr i toppen står med lille begyndelses bogstav hvordan kan jeg få det med stort.

3. Kan jeg få den til at farve dagen idag (altså TD'en) i en hvid farve så den er mærkeret.

Håber nogle kan hjælpe mig med dette.

**************************************************
**************************************************
**************************************************
Min kode er:

<%@ Language=VBScript %>
<% Option Explicit %>
<!--#include file="include/database.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<%
Response.Buffer = True
Session.LCID = 1030
%>
<head>
<title>Kalender</title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
<meta http-equiv="content-language" content="dan" />
<link rel="stylesheet" type="text/css" href="include/style.css" title="style" />
</head>
<body bgcolor="#ffffff">
<%
Dim themonth, theyear, firstday, thefirstDate, theleap, theleapNumbers, thelastDate, thelastYear, thenextYear, thelastMonth, thenextMonth
Dim dateCounter, weekCount, DateEnd, DateBegin, dateSelect, thefirstDay, thelastDay, strSQL

themonth = request.querystring("month")
theyear = request.querystring("year")

If themonth = "" Then
    themonth = Month(Date)
End If

If theyear = "" Then
    theyear = Year(Date)
End If

firstday = Weekday(CDate(themonth & "/" & 1 & "/" & theyear))

theleapNumbers = theyear / 4
theleap = (theleapNumbers) - Round(theleapNumbers)
If themonth = 2 Then
    If theleap <> 0 Then
        thelastDate = 28
    Else
        thelastDate = 29
    End If
ElseIf ((themonth = 4) OR (themonth = 6) OR (themonth = 9) OR (themonth = 11)) Then
    thelastDate = 30
Else
    thelastDate = 31
End If

thelastMonth = themonth - 1
thelastYear = theyear
If thelastMonth < 1 Then
    thelastMonth = 12
    thelastYear = thelastYear - 1
End If

thenextMonth = themonth + 1
thenextYear = theyear
If thenextMonth > 12 Then
    thenextMonth = 1
    thenextYear = thenextYear + 1
End If

dateCounter = 1
weekCount = 1

DateEnd = thelastDate
DateBegin = thefirstDate

' HER STARTER LAYOUT FOR KALENDEREN
Dim Weekday_Font, Weekday_Font_Size, Weekday_Font_Color, Weekday_Background_Color, Date_Font, Date_Font_Size, Date_Font_Color, Date_Background_Color, Event_Font, Event_Font_Size, Event_Font_Color, Cell_Width, Cell_Height, Cell_Background_Color, Border_Size, Border_Color

Weekday_Font = "Tahoma"
Weekday_Font_Size = "1"
Weekday_Font_Color = "#FFCC33"
Weekday_Background_Color = "#3366CC"
Date_Font = "Tahoma"
Date_Font_Size = "1"
Date_Font_Color = "#FF0000"
Date_Background_Color = "#F0F0F0"
Event_Font = "Tahoma"
Event_Font_Size = "1"
Event_Font_Color = "#000000"
Cell_Width = "30"
Cell_Height = "23"
Cell_Background_Color = "#CCCCCC"
Border_Size = "1"
Border_Color = "#000000"
%>

<!-- HER STARTER TABEL OPSÆTNINGEN -->
<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
  <td align="center">
  <table border="0" cellpadding="2" cellspacing="0" width="100%">
    <tr>
    <td align="left" valign="bottom"><font size="1" color=""><b>
    <a href="calendar.asp?month=<%=thelastMonth%>&year=<%=thelastYear%>"><%=MonthName(thelastMonth)%></a>
    </b></font></td>
    <td align="center" valign="bottom"><font size="2"><b><%=MonthName(theMonth)%>&nbsp;<%=theyear%></b></font></td>
    <td align="right" valign="bottom"><font size="1"><b>
    <a href="calendar.asp?month=<%=thenextMonth%>&year=<%=thenextYear%>"><%=MonthName(thenextMonth)%></a>
    </b></font></td>
    </tr>
  </table>
  </td>
</tr>
<tr>
  <td>
  <table border="0" cellpadding="0" cellspacing="0" align="center">
    <tr>
    <td bgcolor="#000000">
      <table border="0" cellpadding="2" cellspacing="1">
      <tr>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Søn</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Man</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Tir</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Ons</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Tor</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Fre</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Lør</b></font>
        </td>
      </tr>
      <tr>
<%
Do while weekCount <= 7
dateSelect = themonth & "/" & dateCounter & "/" & theyear
%>
        <% If (weekCount < thefirstDay) OR (dateCounter > thelastDate) Then %>
        <td height="<%=Cell_Height%>" bgcolor="<%=Cell_Background_Color%>"><img src="images/clear.gif" height="1" width="1"></td>
        <% else %>
        <td height="<%=Cell_Height%>" bgcolor="<%=Date_Background_Color%>" valign="top">
        <a href="date.asp?date=<%=dateSelect%>">
        <font face="<%=Date_Font%>" size="<%=Date_Font_Size%>" color="<%=Date_Font_Color%>"><b><%=dateCounter%></b></font>
        <font face="<%=Event_Font%>" size="<%=Event_Font_Size%>" color="<%=Event_Font_Color%>">
<%
Call OpenDB 'ÅBNING AF DATABASE

strSQL = "SELECT * FROM Events"
Set objRS = objConn.Execute(strSQL)

Do while NOT objRS.EOF
rsdate = objRS("Date")
If (Day(rsdate) = dateCounter) AND (Month(rsdate) = CInt(themonth)) AND (Year(rsdate) = CInt(theyear)) Then
%>
<br>
<%=objRS("Event_Name")%>
<%
End If
objConn.movenext
Loop
objConn.close
%>
        </font></a>
        </td>
<%
dateCounter = dateCounter + 1
end if

weekCount = weekCount + 1
Loop
weekCount = 1
%>
      </tr>
<% Do while dateCounter <= thelastDate %>
      <tr>
<%
Do while weekCount <= 7
dateSelect = themonth & "/" & dateCounter & "/" & theyear
%>
<% If dateCounter > thelastDate Then %>
        <td height="<%=Cell_Height%>" bgcolor="<%=Cell_Background_Color%>">
        <img src="images/clear.gif" height="1" width="1">
        </td>
        <% else %>
        <td height="<%=Cell_Height%>" bgcolor="<%=Date_Background_Color%>" valign="top">
        <a href="date.asp?date=<%=dateSelect%>">
        <font face="<%=Date_Font%>" size="<%=Date_Font_Size%>" color="<%=Date_Font_Color%>"><b><%=dateCounter%></b></font>
        <font face="<%=Event_Font%>" size="<%=Event_Font_Size%>" color="<%=Event_Font_Color%>">
<%
Call OpenDB 'ÅBNING AF DATABASE

strSQL = "SELECT * FROM Events"
Set objRS = objConn.Execute(strSQL)

Do while NOT objRS.EOF
rsdate = objRS("Date")
If (Day(rsdate) = dateCounter) AND (Month(rsdate) = CInt(themonth)) AND (Year(rsdate) = CInt(theyear)) Then
%>
<br>
<%=objRS("Event_Name")%>
<%
End If
objConn.movenext
Loop
objConn.close
%>
        </font></a>
        </td>
<%
dateCounter = dateCounter + 1
end if

weekCount = weekCount + 1
Loop
weekCount = 1
%>
      </tr>
<% Loop %>
      </table>
    </td>
    </tr>
  </table>
  </td>
</tr>
</table>
</body>
</html>
Avatar billede tofte Juniormester
07. december 2005 - 19:37 #1
2) kan evt løses sådan
monthNum=4
response.write UCase(Left(MonthName(monthNum),1))&mid(MonthName(monthNum),2,len(MonthName(monthNum)))
Avatar billede tofte Juniormester
07. december 2005 - 19:52 #2
1) du definerer firstday i toppen men bruger thefirstday i dine ulighed, så hvis du retter firstday i toppen til the firstday, så virker det :-)
Avatar billede tofte Juniormester
07. december 2005 - 19:53 #3
the firstdag skal selvf. være i et ord.
Avatar billede tofte Juniormester
07. december 2005 - 20:00 #4
3) løses vel ved at sammensætte en dato af af dateCounter, themonth og theyear og så teste på dags dato.

if cdate(dateCounter&"-"&themonth&"-"&theyear)=date() then
'brug hvid farve
else
'brug en anden farve
end if

Nu skal du huske at 2100 ikke er et skudår hvis du mener du skal bruge kalenderen så langt frem :-) Husk det er ikke et skudår hvis det kan deles med 100 med mindre 400 også går op i det.
Avatar billede aero Nybegynder
07. december 2005 - 20:08 #5
okay jeg fik klaret det med 1.

http://www.aeronet.dk/calendar/calendar.asp

Men hvis man kigger på sidste dag i dec. 2005 så er det fredag den 31. og jeg ved at nytår falder på lørdagen og hvis man kigger i jan 2006 så er den 1. en søndag altså en forskeld på 1 dag og klikker man til freb. så sker det samme.

Hvad kan det skyldes.

Din kode til spm 2. hvor skal den være !?

og hvor skal vi sætte kode til 3. ind henne.
Avatar billede tofte Juniormester
07. december 2005 - 20:12 #6
Hvis du bytter der hvor du skriver navnet på måneden ud, dvs der hvor der står MonthName(thelastMonth) ud med
UCase(Left(MonthName(thelastMonth),1))&mid(MonthName(thelastMonth),2,len(MonthName(thelastMonth)))
Så får du skrevet det med stort bogstav
Avatar billede tofte Juniormester
07. december 2005 - 20:18 #7
med hensyn til 3. Kunne man lave det sådan.

<% If (weekCount < thefirstDay) OR (dateCounter > thelastDate) Then %>
.... bla bla bla.
<%else%>
<td height="<%=Cell_Height%>" bgcolor="<%
'******************
if cdate(dateCounter&"-"&themonth&"-"&theyear)=date() then
response.write "white"
else
response.write "blue"
end if
'*******************************
%>" valign="top">
<a href="date.asp?date=<%=dateSelect%>">
<font face="<%=Date_Font%>" size="<%=Date_Font_Size%>" color="<%=Date_Font_Color%"><b><%=dateCounter%></b></font>
<font face="<%=Event_Font%>" size="<%=Event_Font_Size%>" color="<%=Event_Font_Color%">
... bla bla ...
Avatar billede aero Nybegynder
07. december 2005 - 21:19 #8
Okay så tror jeg snart det lykkes...

http://www.aeronet.dk/calendar/calendar.asp

1. Hvad var der galt med det med at den ikke skrive de rigtige datoer ved dagene "Kommentar: aero 07/12-2005 20:08:06".

2. Ang at den mærkerer dagen idag...den mærkerer 4 dage og ikke dagen idag..


Håber du lige har tid til det sidste...eller en anden har.



Min kode er NU:
<%@ Language=VBScript %>
<% Option Explicit %>
<!--#include file="include/dsn.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<%
Response.Buffer = True
Session.LCID = 1030
%>
<head>
<title>Kalender</title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
<meta http-equiv="content-language" content="dan" />
<link rel="stylesheet" type="text/css" href="include/style.css" title="style" />
</head>
<body bgcolor="#ffffff">
<%
Dim themonth, theyear, firstday, thefirstDate, theleap, theleapNumbers, thelastDate, thelastYear, thenextYear, thelastMonth, thenextMonth
Dim dateCounter, weekCount, DateEnd, DateBegin, dateSelect, thefirstDay, thelastDay, strSQL

themonth = request.querystring("month")
theyear = request.querystring("year")

If themonth = "" Then
    themonth = Month(Date)
End If

If theyear = "" Then
    theyear = Year(Date)
End If

thefirstday = Weekday(CDate(themonth & "/" & 1 & "/" & theyear))

theleapNumbers = theyear / 4
theleap = (theleapNumbers) - Round(theleapNumbers)
If themonth = 2 Then
    If theleap <> 0 Then
        thelastDate = 28
    Else
        thelastDate = 29
    End If
ElseIf ((themonth = 4) OR (themonth = 6) OR (themonth = 9) OR (themonth = 11)) Then
    thelastDate = 30
Else
    thelastDate = 31
End If

thelastMonth = themonth - 1
thelastYear = theyear
If thelastMonth < 1 Then
    thelastMonth = 12
    thelastYear = thelastYear - 1
End If

thenextMonth = themonth + 1
thenextYear = theyear
If thenextMonth > 12 Then
    thenextMonth = 1
    thenextYear = thenextYear + 1
End If

dateCounter = 1
weekCount = 1

DateEnd = thelastDate
DateBegin = thefirstDate

' HER STARTER LAYOUT FOR KALENDEREN
Dim Weekday_Font, Weekday_Font_Size, Weekday_Font_Color, Weekday_Background_Color, Date_Font, Date_Font_Size, Date_Font_Color, Date_Background_Color, Event_Font, Event_Font_Size, Event_Font_Color, Cell_Width, Cell_Height, Cell_Background_Color, Border_Size, Border_Color

Weekday_Font = "Tahoma"
Weekday_Font_Size = "1"
Weekday_Font_Color = "#FFCC33"
Weekday_Background_Color = "#3366CC"
Date_Font = "Tahoma"
Date_Font_Size = "1"
Date_Font_Color = "#FF0000"
Date_Background_Color = "#F0F0F0"
Event_Font = "Tahoma"
Event_Font_Size = "1"
Event_Font_Color = "#000000"
Cell_Width = "30"
Cell_Height = "23"
Cell_Background_Color = "#CCCCCC"
Border_Size = "1"
Border_Color = "#000000"
%>

<!-- HER STARTER TABEL OPSÆTNINGEN -->
<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
  <td align="center">
  <table border="0" cellpadding="2" cellspacing="0" width="100%">
    <tr>
    <td align="left" valign="bottom"><font size="1" color=""><b>
    <a href="calendar.asp?month=<%=thelastMonth%>&year=<%=thelastYear%>"><%=UCase(Left(MonthName(thelastMonth),1))&mid(MonthName(thelastMonth),2,len(MonthName(thelastMonth)))
%></a>
    </b></font></td>
    <td align="center" valign="bottom"><font size="2"><b><%=UCase(Left(MonthName(theMonth),1))&mid(MonthName(theMonth),2,len(MonthName(theMonth)))
%>&nbsp;<%=theyear%></b></font></td>
    <td align="right" valign="bottom"><font size="1"><b>
    <a href="calendar.asp?month=<%=thenextMonth%>&year=<%=thenextYear%>"><%=UCase(Left(MonthName(thenextMonth),1))&mid(MonthName(thenextMonth),2,len(MonthName(thenextMonth)))
%></a>
    </b></font></td>
    </tr>
  </table>
  </td>
</tr>
<tr>
  <td>
  <table border="0" cellpadding="0" cellspacing="0" align="center">
    <tr>
    <td bgcolor="#000000">
      <table border="0" cellpadding="2" cellspacing="1">
      <tr>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Søn</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Man</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Tir</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Ons</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Tor</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Fre</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Lør</b></font>
        </td>
      </tr>
      <tr>
<%
Do while weekCount <= 7
dateSelect = themonth & "/" & dateCounter & "/" & theyear
%>
        <% If (weekCount < thefirstDay) OR (dateCounter > thelastDate) Then %>
        <td height="<%=Cell_Height%>" bgcolor="<%=Cell_Background_Color%>"><img src="images/clear.gif" height="1" width="1"></td>
        <% else %>
        <td height="<%=Cell_Height%>" bgcolor="
        <% 'HER FINDER DEN UD AF HVILKEN DAG DER ER IDAG ALTSÅ DD. OG FARVER DAGEN GRØN.
        If cdate(dateCounter&"-"&themonth&"-"&theyear)=date() then
        response.write "#00CC33"
        else
        response.write Date_Background_Color
        end if
        %>
        " valign="top">
        <a href="date.asp?date=<%=dateSelect%>">
        <font face="<%=Date_Font%>" size="<%=Date_Font_Size%>" color="<%=Date_Font_Color%>"><b><%=dateCounter%></b></font>
        <font face="<%=Event_Font%>" size="<%=Event_Font_Size%>" color="<%=Event_Font_Color%>">
<%
Call OpenDB 'ÅBNING AF DATABASE

strSQL = "SELECT * FROM Events"
Set objRS = objConn.Execute(strSQL)

Do while NOT objRS.EOF
rsdate = objRS("Date")
If (Day(rsdate) = dateCounter) AND (Month(rsdate) = CInt(themonth)) AND (Year(rsdate) = CInt(theyear)) Then
%>
<br>
<%=objRS("Event_Name")%>
<%
End If
objConn.movenext
Loop
objConn.close
%>
        </font></a>
        </td>
<%
dateCounter = dateCounter + 1
end if

weekCount = weekCount + 1
Loop
weekCount = 1
%>
      </tr>
<% Do while dateCounter <= thelastDate %>
      <tr>
<%
Do while weekCount <= 7
dateSelect = themonth & "/" & dateCounter & "/" & theyear
%>
<% If dateCounter > thelastDate Then %>
        <td height="<%=Cell_Height%>" bgcolor="<%=Cell_Background_Color%>">
        <img src="images/clear.gif" height="1" width="1">
        </td>
        <% else %>
        <td height="<%=Cell_Height%>" bgcolor="<%=Date_Background_Color%>" valign="top">
        <a href="date.asp?date=<%=dateSelect%>">
        <font face="<%=Date_Font%>" size="<%=Date_Font_Size%>" color="<%=Date_Font_Color%>"><b><%=dateCounter%></b></font>
        <font face="<%=Event_Font%>" size="<%=Event_Font_Size%>" color="<%=Event_Font_Color%>">
<%
Call OpenDB 'ÅBNING AF DATABASE

strSQL = "SELECT * FROM Events"
Set objRS = objConn.Execute(strSQL)

Do while NOT objRS.EOF
rsdate = objRS("Date")
If (Day(rsdate) = dateCounter) AND (Month(rsdate) = CInt(themonth)) AND (Year(rsdate) = CInt(theyear)) Then
%>
<br>
<%=objRS("Event_Name")%>
<%
End If
objConn.movenext
Loop
objConn.close
%>
        </font></a>
        </td>
<%
dateCounter = dateCounter + 1
end if

weekCount = weekCount + 1
Loop
weekCount = 1
%>
      </tr>
<% Loop %>
      </table>
    </td>
    </tr>
  </table>
  </td>
</tr>
</table>
</body>
</html>
Avatar billede tofte Juniormester
07. december 2005 - 21:56 #9
Har vist bildt dig noget ind. Du skal rykke dit farve valg en tand ned så den istedet kommer til at stå ved den næste Date_Background_Color.
Avatar billede aero Nybegynder
07. december 2005 - 22:15 #10
hmm okay så men så farver den helt forkert...
http://www.aeronet.dk/calendar/calendar.asp

min kode er nu:
<%@ Language=VBScript %>
<% Option Explicit %>
<!--#include file="include/dsn.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<%
Response.Buffer = True
Session.LCID = 1030
%>
<head>
<title>Kalender</title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
<meta http-equiv="content-language" content="dan" />
<link rel="stylesheet" type="text/css" href="include/style.css" title="style" />
</head>
<body bgcolor="#ffffff">
<%
Dim themonth, theyear, firstday, thefirstDate, theleap, theleapNumbers, thelastDate, thelastYear, thenextYear, thelastMonth, thenextMonth
Dim dateCounter, weekCount, DateEnd, DateBegin, dateSelect, thefirstDay, thelastDay, strSQL

themonth = request.querystring("month")
theyear = request.querystring("year")

If themonth = "" Then
    themonth = Month(Date)
End If

If theyear = "" Then
    theyear = Year(Date)
End If

thefirstday = Weekday(CDate(themonth & "/" & 1 & "/" & theyear))

theleapNumbers = theyear / 4
theleap = (theleapNumbers) - Round(theleapNumbers)
If themonth = 2 Then
    If theleap <> 0 Then
        thelastDate = 28
    Else
        thelastDate = 29
    End If
ElseIf ((themonth = 4) OR (themonth = 6) OR (themonth = 9) OR (themonth = 11)) Then
    thelastDate = 30
Else
    thelastDate = 31
End If

thelastMonth = themonth - 1
thelastYear = theyear
If thelastMonth < 1 Then
    thelastMonth = 12
    thelastYear = thelastYear - 1
End If

thenextMonth = themonth + 1
thenextYear = theyear
If thenextMonth > 12 Then
    thenextMonth = 1
    thenextYear = thenextYear + 1
End If

dateCounter = 1
weekCount = 1

DateEnd = thelastDate
DateBegin = thefirstDate

' HER STARTER LAYOUT FOR KALENDEREN
Dim Weekday_Font, Weekday_Font_Size, Weekday_Font_Color, Weekday_Background_Color, Date_Font, Date_Font_Size, Date_Font_Color, Date_Background_Color, Event_Font, Event_Font_Size, Event_Font_Color, Cell_Width, Cell_Height, Cell_Background_Color, Border_Size, Border_Color

Weekday_Font = "Tahoma"
Weekday_Font_Size = "1"
Weekday_Font_Color = "#FFCC33"
Weekday_Background_Color = "#3366CC"
Date_Font = "Tahoma"
Date_Font_Size = "1"
Date_Font_Color = "#FF0000"
Date_Background_Color = "#F0F0F0"
Event_Font = "Tahoma"
Event_Font_Size = "1"
Event_Font_Color = "#000000"
Cell_Width = "30"
Cell_Height = "23"
Cell_Background_Color = "#CCCCCC"
Border_Size = "1"
Border_Color = "#000000"
%>

<!-- HER STARTER TABEL OPSÆTNINGEN -->
<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
  <td align="center">
  <table border="0" cellpadding="2" cellspacing="0" width="100%">
    <tr>
    <td align="left" valign="bottom"><font size="1" color=""><b>
    <a href="calendar.asp?month=<%=thelastMonth%>&year=<%=thelastYear%>"><%=UCase(Left(MonthName(thelastMonth),1))&mid(MonthName(thelastMonth),2,len(MonthName(thelastMonth)))
%></a>
    </b></font></td>
    <td align="center" valign="bottom"><font size="2"><b><%=UCase(Left(MonthName(theMonth),1))&mid(MonthName(theMonth),2,len(MonthName(theMonth)))
%>&nbsp;<%=theyear%></b></font></td>
    <td align="right" valign="bottom"><font size="1"><b>
    <a href="calendar.asp?month=<%=thenextMonth%>&year=<%=thenextYear%>"><%=UCase(Left(MonthName(thenextMonth),1))&mid(MonthName(thenextMonth),2,len(MonthName(thenextMonth)))
%></a>
    </b></font></td>
    </tr>
  </table>
  </td>
</tr>
<tr>
  <td>
  <table border="0" cellpadding="0" cellspacing="0" align="center">
    <tr>
    <td bgcolor="#000000">
      <table border="0" cellpadding="2" cellspacing="1">
      <tr>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Søn</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Man</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Tir</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Ons</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Tor</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Fre</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Lør</b></font>
        </td>
      </tr>
      <tr>
<%
Do while weekCount <= 7
dateSelect = themonth & "/" & dateCounter & "/" & theyear
%>
        <% If (weekCount < thefirstDay) OR (dateCounter > thelastDate) Then %>
        <td height="<%=Cell_Height%>" bgcolor="<%=Cell_Background_Color%>"><img src="images/clear.gif" height="1" width="1"></td>
        <% else %>
        <td height="<%=Cell_Height%>" bgcolor="<%=Date_Background_Color%>" valign="top">
        <a href="date.asp?date=<%=dateSelect%>">
        <font face="<%=Date_Font%>" size="<%=Date_Font_Size%>" color="<%=Date_Font_Color%>"><b><%=dateCounter%></b></font>
        <font face="<%=Event_Font%>" size="<%=Event_Font_Size%>" color="<%=Event_Font_Color%>">
<%
Call OpenDB 'ÅBNING AF DATABASE

strSQL = "SELECT * FROM Events"
Set objRS = objConn.Execute(strSQL)

Do while NOT objRS.EOF
rsdate = objRS("Date")
If (Day(rsdate) = dateCounter) AND (Month(rsdate) = CInt(themonth)) AND (Year(rsdate) = CInt(theyear)) Then
%>
<br>
<%=objRS("Event_Name")%>
<%
End If
objConn.movenext
Loop
objConn.close
%>
        </font></a>
        </td>
<%
dateCounter = dateCounter + 1
end if

weekCount = weekCount + 1
Loop
weekCount = 1
%>
      </tr>
<% Do while dateCounter <= thelastDate %>
      <tr>
<%
Do while weekCount <= 7
dateSelect = themonth & "/" & dateCounter & "/" & theyear
%>
<% If dateCounter > thelastDate Then %>
        <td height="<%=Cell_Height%>" bgcolor="<%=Cell_Background_Color%>">
        <img src="images/clear.gif" height="1" width="1">
        </td>
        <% else %>
        <td height="<%=Cell_Height%>" bgcolor="
        <% 'HER FINDER DEN UD AF HVILKEN DAG DER ER IDAG ALTSÅ DD. OG FARVER DAGEN GRØN.
        If cdate(dateCounter&"-"&themonth&"-"&theyear)=date() then
        response.write "#00CC33"
        else
        response.write Date_Background_Color
        end if
        %>
        " valign="top">
        <a href="date.asp?date=<%=dateSelect%>">
        <font face="<%=Date_Font%>" size="<%=Date_Font_Size%>" color="<%=Date_Font_Color%>"><b><%=dateCounter%></b></font>
        <font face="<%=Event_Font%>" size="<%=Event_Font_Size%>" color="<%=Event_Font_Color%>">
<%
Call OpenDB 'ÅBNING AF DATABASE

strSQL = "SELECT * FROM Events"
Set objRS = objConn.Execute(strSQL)

Do while NOT objRS.EOF
rsdate = objRS("Date")
If (Day(rsdate) = dateCounter) AND (Month(rsdate) = CInt(themonth)) AND (Year(rsdate) = CInt(theyear)) Then
%>
<br>
<%=objRS("Event_Name")%>
<%
End If
objConn.movenext
Loop
objConn.close
%>
        </font></a>
        </td>
<%
dateCounter = dateCounter + 1
end if

weekCount = weekCount + 1
Loop
weekCount = 1
%>
      </tr>
<% Loop %>
      </table>
    </td>
    </tr>
  </table>
  </td>
</tr>
</table>
</body>
</html>
Avatar billede tofte Juniormester
07. december 2005 - 22:15 #11
har desværre ikke mere tid i dag, prøver at huske det i morgen. Andre er også velkommen til at byde ind
Avatar billede aero Nybegynder
07. december 2005 - 22:35 #12
helt iorden vi snakkes bare ved imorgen så hvis ikke en anden har fundet problemmet..

men tak for det vi fik nået
Avatar billede tofte Juniormester
07. december 2005 - 23:53 #13
Nu burde det virke. Jeg har rettet i dit. Resultatet er at finde på http://rasmus.fjordloekke.dk/calendar.asp

Det kan godt være at farverne ikke er helt som du vil have dem, men dem kan du jo rette. Jeg har rettet følgende:
Fjernet overskydende mellemrum ved
<td height="<%=Cell_Height%>" bgcolor="<% 'HER FINDER DEN UD AF HVILKEN DAG DER ER IDAG ALTSÅ DD. OG FARVER DAGEN GRØN.
        If cdate(dateCounter&"-"&themonth&"-"&theyear)=date() then
        response.write "#00CC33"
        else
        response.write Date_Background_Color
        end if
        %>" valign="top">

således at der ikke er mellemrum mellem %> og " og %> "

'********Gammel linie
'********thefirstday = Weekday(CDate(themonth & "/" & 1 & "/" & theyear))
'*** Ny linie
thefirstday = Weekday(CDate(1 & "/" & themonth & "/" & theyear))
Avatar billede aero Nybegynder
08. december 2005 - 09:24 #14
okay det virker nu det med at mærkerer dagen idag

http://www.aeronet.dk/calendar/calendar.asp

så er det bare det med de rigtige datoer.
og læg venligst et svar næste gang
Avatar billede tofte Juniormester
08. december 2005 - 09:45 #15
men det virker godt nok i min kode. Se http://rasmus.fjordloekke.dk/calendar.asp.

Den kode jeg bruger minder om din, dog med den undtagelse at jeg har fjernet databaseadgangen da jeg ikke lige gad oprette en database:
<%@ Language=VBScript %>
<% Option Explicit %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<%
Response.Buffer = True
Session.LCID = 1030
%>
<head>
<title>Kalender</title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
<meta http-equiv="content-language" content="dan" />
<link rel="stylesheet" type="text/css" href="include/style.css" title="style" />
</head>
<body bgcolor="#ffffff">
<%
Dim themonth, theyear, firstday, thefirstDate, theleap, theleapNumbers, thelastDate, thelastYear, thenextYear, thelastMonth, thenextMonth
Dim dateCounter, weekCount, DateEnd, DateBegin, dateSelect, thefirstDay, thelastDay, strSQL

themonth = request.querystring("month")
theyear = request.querystring("year")

If themonth = "" Then
    themonth = Month(Date)
End If

If theyear = "" Then
    theyear = Year(Date)
End If

'Gammel linie
'thefirstday = Weekday(CDate(themonth & "/" & 1 & "/" & theyear))
thefirstday = Weekday(CDate(1 & "/" & themonth & "/" & theyear))
theleapNumbers = theyear / 4
theleap = (theleapNumbers) - Round(theleapNumbers)
If themonth = 2 Then
    If theleap <> 0 Then
        thelastDate = 28
    Else
        thelastDate = 29
    End If
ElseIf ((themonth = 4) OR (themonth = 6) OR (themonth = 9) OR (themonth = 11)) Then
    thelastDate = 30
Else
    thelastDate = 31
End If

thelastMonth = themonth - 1
thelastYear = theyear
If thelastMonth < 1 Then
    thelastMonth = 12
    thelastYear = thelastYear - 1
End If

thenextMonth = themonth + 1
thenextYear = theyear
If thenextMonth > 12 Then
    thenextMonth = 1
    thenextYear = thenextYear + 1
End If

dateCounter = 1
weekCount = 1

DateEnd = thelastDate
DateBegin = thefirstDate

' HER STARTER LAYOUT FOR KALENDEREN
Dim Weekday_Font, Weekday_Font_Size, Weekday_Font_Color, Weekday_Background_Color, Date_Font, Date_Font_Size, Date_Font_Color, Date_Background_Color, Event_Font, Event_Font_Size, Event_Font_Color, Cell_Width, Cell_Height, Cell_Background_Color, Border_Size, Border_Color

Weekday_Font = "Tahoma"
Weekday_Font_Size = "1"
Weekday_Font_Color = "#FFCC33"
Weekday_Background_Color = "#3366CC"
Date_Font = "Tahoma"
Date_Font_Size = "1"
Date_Font_Color = "#FF0000"
Date_Background_Color = "#F0F0F0"
Event_Font = "Tahoma"
Event_Font_Size = "1"
Event_Font_Color = "#000000"
Cell_Width = "30"
Cell_Height = "23"
Cell_Background_Color = "#CCCCCC"
Border_Size = "1"
Border_Color = "#000000"
%>

<!-- HER STARTER TABEL OPSÆTNINGEN -->
<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
  <td align="center">
  <table border="0" cellpadding="2" cellspacing="0" width="100%">
    <tr>
    <td align="left" valign="bottom"><font size="1" color=""><b>
    <a href="calendar.asp?month=<%=thelastMonth%>&year=<%=thelastYear%>"><%=UCase(Left(MonthName(thelastMonth),1))&mid(MonthName(thelastMonth),2,len(MonthName(thelastMonth)))
%></a>
    </b></font></td>
    <td align="center" valign="bottom"><font size="2"><b><%=UCase(Left(MonthName(theMonth),1))&mid(MonthName(theMonth),2,len(MonthName(theMonth)))
%>&nbsp;<%=theyear%></b></font></td>
    <td align="right" valign="bottom"><font size="1"><b>
    <a href="calendar.asp?month=<%=thenextMonth%>&year=<%=thenextYear%>"><%=UCase(Left(MonthName(thenextMonth),1))&mid(MonthName(thenextMonth),2,len(MonthName(thenextMonth)))
%></a>
    </b></font></td>
    </tr>
  </table>
  </td>
</tr>
<tr>
  <td>
  <table border="0" cellpadding="0" cellspacing="0" align="center">
    <tr>
    <td bgcolor="#000000">
      <table border="0" cellpadding="2" cellspacing="1">
      <tr>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Søn</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Man</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Tir</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Ons</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Tor</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Fre</b></font>
        </td>
        <td width="<%=Cell_Width%>" align="center" bgcolor="<%=Weekday_Background_Color%>">
        <font face="<%=Weekday_Font%>" size="<%=Weekday_Font_Size%>" color="<%=Weekday_Font_Color%>"><b>Lør</b></font>
        </td>
      </tr>
      <tr>
<%
Do while weekCount <= 7
dateSelect = themonth & "/" & dateCounter & "/" & theyear
%>
        <% If (weekCount < thefirstDay) OR (dateCounter > thelastDate) Then %>
        <td height="<%=Cell_Height%>" bgcolor="<%=Cell_Background_Color%>"><img src="images/clear.gif" height="1" width="1"></td>
        <% else %>
        <td height="<%=Cell_Height%>" bgcolor="<%=Date_Background_Color%>" valign="top">
        <a href="date.asp?date=<%=dateSelect%>">
        <font face="<%=Date_Font%>" size="<%=Date_Font_Size%>" color="<%=Date_Font_Color%>"><b><%=dateCounter%></b></font>
        <font face="<%=Event_Font%>" size="<%=Event_Font_Size%>" color="<%=Event_Font_Color%>">
        </font></a>
        </td>
<%
dateCounter = dateCounter + 1
end if

weekCount = weekCount + 1
Loop
weekCount = 1
%>
      </tr>
<% Do while dateCounter <= thelastDate %>
      <tr>
<%
Do while weekCount <= 7
dateSelect = themonth & "/" & dateCounter & "/" & theyear
%>
<% If dateCounter > thelastDate Then %>
        <td height="<%=Cell_Height%>" bgcolor="<%=Cell_Background_Color%>">
        <img src="images/clear.gif" height="1" width="1">
        </td>
        <% else %>
        <td height="<%=Cell_Height%>" bgcolor="<% 'HER FINDER DEN UD AF HVILKEN DAG DER ER IDAG ALTSÅ DD. OG FARVER DAGEN GRØN.
        If cdate(dateCounter&"-"&themonth&"-"&theyear)=date() then
        response.write "#00CC33"
        else
        response.write Date_Background_Color
        end if
        %>" valign="top">
        <a href="date.asp?date=<%=dateSelect%>">
        <font face="<%=Date_Font%>" size="<%=Date_Font_Size%>" color="<%=Date_Font_Color%>"><b><%=dateCounter%></b></font>
        <font face="<%=Event_Font%>" size="<%=Event_Font_Size%>" color="<%=Event_Font_Color%>">
        </font></a>
        </td>
<%
dateCounter = dateCounter + 1
end if

weekCount = weekCount + 1
Loop
weekCount = 1
%>
      </tr>
<% Loop %>
      </table>
    </td>
    </tr>
  </table>
  </td>
</tr>
</table>
</body>
</html>
Avatar billede aero Nybegynder
08. december 2005 - 11:27 #16
tror jeg ved hvor fejlen er med kan ikke lige se hvordan jeg retter den..

kigger man på din så starter du med Søn til Lør jeg stareter med Man til Søn.. hvordan retter du i koden så den ved at første dag i kalenderen er Mandag og ikke søndag !?
Avatar billede tofte Juniormester
08. december 2005 - 16:34 #17
Problemer er, at søndag er den første dag i ugen(i hvert fald for amerikanerne). Så når du bruger WeekDay(d) på en dato(d) som er en søndag så returnerer den 1 og ikke 7 som du gerne vil have. Hvis dette skal løses er du nød til at trække en fra thefirstday og sætte den lig 7 hvis den så bliver nul. På den måde får søndag værdien 7 og mandag 1 osv.
Du kan læse om weekDay her http://www.devguru.com/technologies/vbscript/13987.asp
Avatar billede tofte Juniormester
08. december 2005 - 16:43 #18
hmm, det nemmeste er som linket hentyder at bruge WeekDay(d,2) så bliver mandag den første dag i ugen.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester