出来るのだASP Q&A掲示板(過去LOG)
訪問数 52046
昨日 889
今日 776 【PR】 パソコン入門からIT専門書まで幅広く取り揃えています。セブン-イレブン受取り手数料無料のセブンアンドワイ。 |
![]() ![]() ![]() ![]() ![]() |
[5583] calender仕上がりソースファイル 皆様ありがとうございました また勉強してきます |
投稿者:さとしさん 2006/01/12 15:56:16 |
<%@ language=vbscript %> <% Option Explicit %> <html> <head> <title>カレンダー表示</title> </head> <body bgcolor="#f5f5f5"> <% Dim ilastday Dim idate Dim Ttable Dim Ytable Dim iyear Dim imonth Const MINI_YEAR = 0 Const MAX_YEAR = 9999 Const MINI_MONTH = 1 Const MAX_MONTH = 12 'formからのpostがある場合と無い場合の切り分け If Request.Form("year") = "" Then '入力データの取得 "年" iyear = year(now) Else iyear = Request.Form("year") End if If Isnumeric(iyear) Then '入力値が整数であるか、また入力データが0〜9999であるか条件分岐 If MINI_YEAR > iyear and MAX_YEAR < iyear Then iyear = year(now) End if else iyear = Request.Form("year") End if If Request.Form("month") = "" Then '入力データの取得 "月" imonth = month(now) Else imonth = Request.Form("month") End if If isnumeric(imonth) Then '入力値が整数であるか、また入力データが1〜12であるか条件分岐 If MINI_MONTH >= imonth and MAX_MONTH <= imonth Then imonth = month(now) End if else imonth = month(now) End if idate = 1-Weekday(Dateserial(iyear,imonth,1))+1 '週の一日目計算 ilastday = Day(Dateserial(iyear,imonth+1,1-1)) '月の最終日計算 Response.Write "<div>西暦" & iyear & "年" & imonth & "月</div>" Response.Write "<table border=0>" 'テーブルの作成 Response.Write "<tr>" For Ytable = 0 To 6 '曜日欄の作成 Weekdaynameで曜日を返していく response.write "<td width=50 height=25 align=center>" If (Weekday(Ytable) = 7) Then Response.Write "<font color=red>" End if If (Weekday(Ytable) = 6) Then Response.Write "<font color=blue>" End If Response.Write Weekdayname(Ytable+1,true) Response.Write "</td>" Next Response.Write "</tr>" For Ttable = 0 To 5 'カレンダ、月の1日目から月の最終日の表示 Response.Write "<tr>" For Ytable = 0 To 6 If idate > 0 and idate <= ilastday Then 'カレンダに条件に見合った日付が入るかどうか Response.Write "<td width=50 height=50 align=center>" Select Case Ytable Case 0 Response.Write "<font color=red>" & idate & "</font>" Case 6 Response.Write "<font color=blue>" & idate & "</font>" Case Else Response.Write "<font color=black>" & idate & "</font>" End Select Response.Write "</td>" Else Response.Write "<td width=50 height=50 align=center>" & "" Response.Write "</td>" End If idate = idate + 1 'カレンダの枠の中に該当した日付を入力していく If idate > ilastday Then '繰り返し処理から抜け出す Exit For End If Next Response.Write "</tr>" If idate > ilastday Then Exit For End If Next Response.Write "</table>" Response.Write "今日は" & CDate(now()) %> <form method = "post" action = "calender.asp"> <!-- 入力フォーム 年 月 --> <input Type = "text" name = "year" size = "8" value = "<% response.write year(now) %>">年 <input Type = "text" name = "month" size = "4" value = "<% response.write month(now) %>">月 <input Type = "submit" value = "カレンダ表示" > <!-- フォームでsubmitしたらrequest.formに投げかける --> </body> </html> |
![]() ![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
TreeBBS For ASP V.0.1.3 |