News... | Hack-Acad | Downloads | Web-Projekte | System-Check | Kontakt
HACKACAD - ASP Kalender

Folgender Quellcode erzeugt einen simplen Monats-Kalender in ASP:

 
<%
sub_aktion = request("go")
fehler = " "

heute = request("heute")

if sub_aktion = "Suche" then
	heute = request("st") & "." & request("sm") & "." & request("sj")
	
	if NOT IsDate(heute) then 
		fehler = "<span style=""color:#ff0000; font-weight:800;""> "_
		& "Ungültiges Datum!</span>"
	end if
end if

splitDate date(), mark_day, mark_month, mark_year

if heute = "" or NOT IsDate(heute) then
heute = date()
end if

MArray = array ("", "Januar", "Februar", "März", "April" , "Mai", "Juni", _
 "Juli", "August", "September", "Oktober", "November", "Dezember")

hTag	= ""
hMonat	= ""
hJahr	= ""
eTag	= ""
lTag	= ""

splitDate heute, hTag, hMonat, hJahr

erster_tag 	= DateAdd("d", -hTag + 1 , heute)
splitDate erster_tag, eTag, "", ""

letzter_tag = DateAdd("d", -1 , DateAdd("m", + 1 , erster_tag))
splitDate letzter_tag, lTag, "", ""

vorHeute 	= DateAdd("m", -1, erster_tag)
nachHeute	= DateAdd("m", +1, erster_tag)

if weekday(erster_tag) = 1 then
	start = 7
else
	start = weekday(erster_tag) -1 
end if

'### Aufklapp Status der Datumsuche
	cmd = request("cmd")
	
	if cmd = "" then 
		cmd   = "p"
		show  = "+"
		cflag = "m"
	elseif cmd = "p" then 
		cmd   = "m"
		show  = "-"
		cflag = "p"
	elseif cmd = "m" then 
		cmd   = "p"
		show  = "+"
		cflag = "m"
	end if
'### Ende Aufklapp Status der Datumsuche

%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<title>ASP Calendar</title>

<style type="text/css">
<!--
a { color:#ffffff; text-decoration:none; font-weight:800; }
a:hover { color:#ff0000; }

input { height:24px; background-color: #D2D2FF; color:#000000; font-weight:800; }
-->
</style>

</head>

<body>

<%
	table_width = 420
	td_width	= 60
	td_colspan	= 7
%>

<table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
	<td valign="middle" width="100%" height="100%" align="center">

<table width="<%=table_width%>" cellspacing="0" cellpadding="0" border="0">
<tr><td><%=fehler%></td></tr>
</table>

<table width="<%=table_width%>" cellspacing="0" cellpadding="0" border="0" _
style="border:4px double #0000ff;">
<tr bgcolor="#BFBFFF">
<td width="<%=td_width%>" style="border-bottom: 1px solid #0000ff;"> 
<a href="index.asp?heute=<%=vorHeute%>&cmd=<%=cflag%>"><<</a></td>
<td width="<%=table_width-(2 * td_width)%>" align="center" _
style="border-bottom: 1px solid #0000ff;" colspan="<%=td_colspan-2%>">
<b><%=MArray(hMonat)%> <%=hJahr%></b></td>
<td align="right" width="<%=td_width%>" style="border-bottom: 1px solid #0000ff;">
<a href="index.asp?heute=<%=nachHeute%>&cmd=<%=cflag%>">>></a> </td>	
</tr>

<tr bgcolor="#D2D2FF">
<td width="<%=td_width%>" align="center" style="border-top: 1px solid #0000ff;">Mo</td>
<td width="<%=td_width%>" align="center" style="border-top: 1px solid #0000ff;">Di</td>	
<td width="<%=td_width%>" align="center" style="border-top: 1px solid #0000ff;">Mi</td>	
<td width="<%=td_width%>" align="center" style="border-top: 1px solid #0000ff;">Do</td>
<td width="<%=td_width%>" align="center" style="border-top: 1px solid #0000ff;">Fr</td>
<td width="<%=td_width%>" align="center" _ 
style="border-left:1px solid #444444; border-top: 1px solid #0000ff;">Sa</td>
<td width="<%=td_width%>" align="center" style="border-top: 1px solid #0000ff;">So</td>
</tr>

    <%
    j = 1
    k = 0

    response.write "<tr bgcolor=""#DFDFDF"">"
		
    for i = 1 to 7
		
        bgc 	= ""
        style 	= "border-top: 1px solid #0000ff;"
			
        if i = 6 or i = 7 then bgc 	= "#FF9797"
        if i = 6 then style = style & "border-left:1px solid #444444;"
			
        if i < start then 
        response.write "<td bgcolor=""" & bgc & """ align=""center"" width=""" & _
        td_width & """ style=""" & style & """> </td>" & vbCrLf & vbTab
        else
            if i = CInt(mark_day) and hMonat = mark_month and hJahr = mark_year then
            response.write "<td bgcolor=""" & bgc & """ align=""center"" width=""" & _
            td_width & """ style=""" & style & """><b>" & j & "</b></td>" & vbCrLf & vbTab
            else
            response.write "<td bgcolor=""" & bgc & """ align=""center"" width=""" & _
            td_width & """ style=""" & style & """>" & j & "</td>" & vbCrLf & vbTab
            end if
				
            j = j + 1
        end if
    next 
	
    response.write "</tr>"
	
    for i = j to 31
			
        if k = 0 then
            response.write "<tr bgcolor=""#DFDFDF"">" & vbCrLf & vbTab
        end if
			
        k = k + 1
			
        bgc		= ""
        style 	= ""

        if i > CInt(lTag) then
            i_val = " "
        else
            i_val = i
        end if
			
        if k = 6 or k = 7 then bgc = "#FF9797"
        if k = 6 then style = style & "border-left:1px solid #444444;"

        if i = CInt(mark_day) and hMonat = mark_month and hJahr = mark_year then
            bgc = "#BBFFBB"
            response.write "<td style=""" & style & """ bgcolor=""" & _
            bgc & """ align=""center"" width=""" & _
            td_width & """><b>" & i_val & "</b></td>" & vbCrLf & vbTab		
        else
            response.write "<td style=""" & style & """ bgcolor=""" & _
            bgc & """ align=""center"" width=""" & _
            td_width & """>" & i_val & "</td>" & vbCrLf & vbTab		
        end if
						
        if k = 7 then
            response.write "</tr>" & vbCrLf & vbTab
            k = 0
        end if		
			
    next
		
    if k <> 0 then

    for i = k+1 to 7
			
        style 	= ""
        if i = k + 1 then 
            style = "border-top:4px groove #444444; border-left:4px groove #444444;"
        else
            style = "border-top:4px groove #444444;"				
        end if
			   	
        bgc 	= "#BFBFFF"
								
        response.write "<td bgcolor=""" & bgc & """ width=""" & td_width & """ style=""" & _
        style & """> </td>" & vbCrLf & vbTab
				
    next 	
		
			response.write "</tr>" & vbCrLf & vbTab

		end if
%>
<tr bgcolor="#D2D2FF">
   <td style="border-top: 1px solid #0000ff;"> </td>
   <td colspan="5" align="center" style="border-top: 1px solid #0000ff;">Heutiges Datum: <b>
   <a href="index.asp?heute=<%=date()%>"><%=date()%></a></b></td>
   <td align="right" style="border-top: 1px solid #0000ff;">
   <a href="index.asp?heute=<%=heute%>&cmd=<%=cmd%>" style="font-size:16pt"><%=show%></a> </td>
</tr>
</table>
	<%
		if show = "-" then
			show_color = "#0000ff"
		else
			show_color = "#ffffff"
		end if
	%>
		
	<table cellpadding="0" cellspacing="0" border="0" width="<%=table_width%>" _
	style="border: 4px double <%=show_color%>">
	<% 	if show = "-" then	%>
	<form method="post" action="index.asp">

	<tr bgcolor="#BFBFFF">
		<td align="center" valign="middle"><b>Tag:</b>
		<select name="st" size="1">
        <%
        for i = 1 to 31
            if i = CInt(mark_day) then
            response.write "<option selected name="" & i & "">" & i & "</option>"
            else
            response.write "<option name="" & i & "">" & i & "</option>"
            end if
            next
        %>
		</select>		
		<b>Monat:</b>
		<select name="sm" size="1">
        <%
        for i = 1 to 12
            if i = CInt(mark_month) then
            response.write "<option selected name="" & i & "">" & i & "</option>"
            else
            response.write "<option name="" & i & "">" & i & "</option>"           
            end if
        next
        %>
		</select>		
	 	<b>Jahr:</b>
		<select name="sj" size="1">
        <%
        for i = (CInt(mark_year) - 3) to (CInt(mark_year) + 3)
            if CStr(i) = mark_year then
            response.write "<option selected name="" & i & "">" & i & "</option>"
            else
            response.write "<option name="" & i & "">" & i & "</option>"
            end if
        next
        %>
		</select>		
		 
		<input type="submit" value="Suche" name="go">
	 	</td>
	</tr>
	<input type="hidden" name="cmd" value="<%=cflag%>">		
	<input type="hidden" name="heute" value="<%=heute%>">
	</form>
<%	
	else
	response.write "<tr><td style=""font-size:16pt""> </td></tr>"
	end if 
%>
	</table>


	</td>
</tr>
</table>

</body>
</html>

<%
function splitDate(ByVal datum, ByRef tag, ByRef monat, ByRef jahr)

	date_array = split(datum,".")

	tag 	= date_array(0)
	monat	= date_array(1)
	jahr	= date_array(2)

end function

%>