| 项目搜索 |
| |
|
代码片段库:
查看代码片段
浏览
| 提交新的代码片段
| 创建代码包
ASP Calender Code
|
类型:
Sample Code (HOWTO) |
类别:
HTML Manipulation
|
许可证:
GNU General Public License |
语言:
Other Language
|
描述:
this is a calendar for asp.
u have to just copy and paste code in your asp file.
http://www.freevbcode.com/ShowCode.Asp?ID=6123
|
该代码片段的版本系列:
片段ID |
下载版本 |
提交时间 |
提交人 |
删除 |
4834 | 1.0 | 2003-11-30 04:53 | cbd001 | |
点击"下载版本"来下载该代码片段.
最新版本的代码片段: 1.0
<%@ language=vbscript%>
<%option explicit%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function month_onchange()
{
form1.submit();
}
function year_onchange()
{
form1.submit();
}
//-->
</SCRIPT>
</HEAD>
<BODY bgcolor=LightSkyBlue>
<style>
a
{
.color="mediumblue"
}
</style>
<form name=form1 action=calendar.asp method=post>
<%
dim change_month
dim change_year
dim diff_days
dim diff_months
dim diff_years
diff_days=0
diff_months=0
diff_years=0
change_month=Request.Form("month")
change_year=Request.Form("year")
if change_month="" then
change_month=month(date())
end if
if change_year="" then
change_year=year(date())
end if
%>
<br><br>
<table>
<tr>
<td>
<select name=month LANGUAGE=javascript onchange="return month_onchange()">
<option value="1" <% if change_month="1" then%> selected <%end if%>>January</option>
<option value="2" <% if change_month="2" then%> selected <%end if%>>Febuary</option>
<option value="3" <% if change_month="3" then%> selected <%end if%>>March</option>
<option value="4" <% if change_month="4" then%> selected <%end if%>>April</option>
<option value="5" <% if change_month="5" then%> selected <%end if%>>May</option>
<option value="6" <% if change_month="6" then%> selected <%end if%>>June</option>
<option value="7" <% if change_month="7" then%> selected <%end if%>>July</option>
<option value="8" <% if change_month="8" then%> selected <%end if%>>August</option>
<option value="9" <% if change_month="9" then%> selected <%end if%>>September</option>
<option value="10" <% if change_month="10" then%> selected <%end if%>>October</option>
<option value="11" <% if change_month="11" then%> selected <%end if%>>November</option>
<option value="12" <% if change_month="12" then%> selected <%end if%>>December</option>
</select>
</td>
<td>
<select name=year LANGUAGE=javascript onchange="return year_onchange()">
<%dim year_display%>
<%for year_display=2003 to 2005%>
<option value=<%=year_display%> <% if int(change_year)=year_display then%> selected <%end if%>><%=year_display%></option>
<%next%>
<!-- <option value="2003" <% if change_year="2003" then%> selected <%end if%>>2003</option>
<option value="2004" <% if change_year="2004" then%> selected <%end if%>>2004</option>
<option value="2005" <% if change_year="2005" then%> selected <%end if%>>2005</option>
<option value="2006" <% if change_year="2006" then%> selected <%end if%>>2006</option>
<option value="2007" <% if change_year="2007" then%> selected <%end if%>>2007</option>
<option value="2008" <% if change_year="2008" then%> selected <%end if%>>2008</option>
<option value="2009" <% if change_year="2009" then%> selected <%end if%>>2009</option>
<option value="2010" <% if change_year="2010" then%> selected <%end if%>>2010</option>
<option value="2011" <% if change_year="2011" then%> selected <%end if%>>2011</option>
<option value="2012" <% if change_year="2012" then%> selected <%end if%>>2012</option>
<option value="2013" <% if change_year="2013" then%> selected <%end if%>>2013</option>
<option value="2014" <% if change_year="2014" then%> selected <%end if%>>2014</option>-->
</select>
</td>
</tr>
</table>
<%
dim temp
dim total_days
dim m
dim month_name
dim next_month_name
dim y
dim to_day
dim first_day
dim first_day_month
dim week_day
dim sys_m
dim sys_y
dim mode_check'SELECT DATE IS LESS THAN SYSTEM DATE
dim i
dim j
dim dat
dim state
dat=1
state=1
m=int(change_month)
month_name=ucase(monthname(m))
y=int(change_year)
sys_m=month(date())
sys_y=year(date())
dim count_months
dim count_years
count_months=0
count_years=0
if y<sys_y then
diff_years=sys_y-y
'if m>=sys_m then
diff_months=((diff_years -1)*12)+(12-m)+sys_m
do while diff_years>count_years
sys_y=y
sys_m=m
do while diff_months>count_months
call get_days(sys_m)
sys_m=sys_m+1
if sys_m=13 then
sys_m=1
count_years=count_years+1
sys_y=sys_y+1
end if
count_months=count_months+1
loop
loop
mode_check="less"
'Response.Write(diff_days)
else if y=sys_y then
if m>sys_m then
do while m>sys_m
call get_days(sys_m)
sys_m=sys_m+1
loop
else
diff_months=sys_m-m
sys_m=m
do while diff_months>count_months
call get_days(sys_m)
sys_m=sys_m+1
count_months=count_months+1
loop
mode_check="less"
end if 'M>SYS_M
else
diff_years=y-sys_y
do while diff_years>count_years
if m>=sys_m then
diff_months=(diff_years*12)+m-sys_m
do while diff_months>count_months
call get_days(sys_m)
sys_m=sys_m+1
if sys_m=13 then
sys_m=1
count_years=count_years+1
sys_y=sys_y+1
end if
count_months=count_months+1
loop
else
diff_months=((diff_years-1)*12)+(12-sys_m)+m
do while diff_months>count_months
call get_days(sys_m)
sys_m=sys_m+1
if sys_m=13 then
sys_m=1
count_years=count_years+1
sys_y=sys_y+1
end if
count_months=count_months+1
loop
end if
loop
end if 'Y=SYS_Y
end if
'Response.Write(diff_days)
to_day=day(date())
week_day=weekday((date()))'IT RETURNS WEEKDAY NO.1-SUNDAY
call get_month(m)
first_day=((diff_days-to_day)mod 7+week_day +1)mod 7
if mode_check="less" then
first_day=week_day-(diff_days+to_day) mod 7 +1
if first_day<0 then
first_day=7+first_day
end if
end if
if first_day <0 then
first_day_month=week_day-first_day
else if first_day=0 then
first_day_month=7
else
first_day_month=first_day
end if
end if
%>
<br><br>
<table bgcolor=DarkBlue>
<font color=MediumBlue><%=month_name%>牋牋<%=y%> </font>
</table>
<table width=30% cellspacing=10><!--FIRST MONTH STARTS FROM HERE-->
<tr>
<td><font color=Red>Sun</font></td>
<td><font color=MediumBlue>Mon</font></td>
<td><font color=MediumBlue>Tue</font></td>
<td><font color=MediumBlue>Wed</font></td>
<td><font color=MediumBlue>Thu</font></td>
<td><font color=MediumBlue>Fri</font></td>
<td><font color=MediumBlue>Sat</font></td>
</tr>
<tr>
<td colspan=7>
<hr>
</td>
</tr>
<%for j=1 to 6%>
<tr>
<%if state=2 then%>
<%for i=1 to 7%>
<td align=center>
<a href="calendar12.asp"><%=dat%></a>
</td>
<%dat=dat+1%>
<%if dat>total_days then%>
<%state=3
exit for%>
<%end if%>
<%next%>
<%end if%>
<%if state=1 then%>
<%for i=1 to first_day_month-1%>
<td>
</td>
<%next%>
<%for i=first_day_month to 7%>
<td align=center>
<a href="calendar12.asp"><%=dat%></a>
</td>
<%dat=dat+1%>
<%next%>
</td>
<%state=2%>
<%end if%>
</tr>
<%next%>
<tr>
<td colspan=7>
<hr>
</td>
</tr>
</table><!--FIRST MONTH ENDS HERE-->
<!--<%
m=m+1
if m=13 then
m=1
y=y+1
end if
%>
<%next_month_name=ucase(monthname(m))%>
<font color=Blue><%=next_month_name%> <%=y%> </font>
<table width=35%>--> <!--SECOND MONTH STARTS FROM HERE-->
<!--<%call get_month(m)%>
<%
if i=7 then
i=1
else
i=i+1
end if
first_day_month=i
state=1
dat=1
%>
<tr>
<td>SUN</TD>
<td>MON</TD>
<td>TUE</TD>
<td>WED</TD>
<td>THU</TD>
<td>FRI</TD>
<td>SAT</TD>
</tr>
<%for j=1 to 6%>
<tr>
<%if state=2 then%>
<%for i=1 to 7%>
<td>
<%=dat%>
</td>
<%dat=dat+1%>
<%if dat>total_days then%>
<%state=3
exit for%>
<%end if%>
<%next%>
<%end if%>
<%if state=1 then%>
<%for i=1 to first_day_month-1%>
<td>
</td>
<%next%>
<%for i=first_day_month to 7%>
<td>
<%=dat%>
</td>
<%dat=dat+1%>
<%next%>
</td>
<%state=2%>
<%end if%>
</tr>
<%next%>
<%for j=1 to 16%>
<tr>
</tr>
<%next%>
</table>--><!--SECOND MONTHS ENDS HERE-->
<%
sub get_month(int)'TO GET NO. OF DAYS IN PARTICULAR MONTH
if m=4 or m=6 or m=9 or m=11 then
total_days=30
'Response.Write(total_days)
else if m=2 and (y mod 4)=0 then
total_days=29
'Response.Write(total_days)
else if m=2 and (y mod 4)<>0 then
total_days=28
'Response.Write(total_days)
else if m=1 or m=3 or m=5 or m=7 or m=8 or m=10 or m=12 then
total_days=31
'Response.Write(total_days)
end if
end if
end if
end if
end sub
sub get_days(int)'TO GET NO. OF DAYS IN PARTICULAR MONTH
if sys_m=4 or sys_m=6 or sys_m=9 or sys_m=11 then
diff_days=diff_days+30
'Response.Write(diff_days)
else if sys_m=2 and (sys_y mod 4)=0 then
diff_days=diff_days+29
'Response.Write(diff_days)
else if sys_m=2 and (sys_y mod 4)<>0 then
diff_days=diff_days+28
'Response.Write(diff_days)
else if sys_m=1 or sys_m=3 or sys_m=5 or sys_m=7 or sys_m=8 or sys_m=10 or sys_m=12 then
diff_days=diff_days+31
'Response.Write(diff_days)
end if
end if
end if
end if
end sub
%>
</form>
<P>?/P>
</BODY>
</HTML>
如果您修改了一个代码片段并且觉得很应该让别人共享,您可以把这作为这个代码片段的最新版本提交上来. |
|