<%@ language=VBScript %>
<% option explicit %>

<%
response.expires = 0

dim i
dim dtDate
dim iYear
dim iMonth
dim sView

iYear= request.form("YEAR") & request.querystring("YEAR")
iMonth = request.form("MONTH") & request.querystring("MONTH")
sView = request.form("VW") & request.querystring("VW")

%>

<html>
<head>
<title>
Lab 8 - Month Information Page</title>"
<meta name="Description" content="ASP lab that tests usage of both the Request.Form and Request.Querystring collections.">
</head>

<body bgcolor="#ffffff">
<h1>
Month Information Page</h1>
<p>

<%

if LEN(sView) > 0 AND NOT (IsNumeric(iYear)) then
  
response.write "<p><strong><em>" & iYear & "</em> is not a number. Please enter a year between 1 and 9999</strong></p>"
  
sView = "" 'set to default form
end if

SELECT CASE sView

    CASE "YR" 'Year detail

        if (iYear < 1) or (iYear > 9999) then
  
     response.write "<p><strong><em>" & iYear & "</em> is an invalid year. Please enter a year between 1 and 9999</strong></p>"
  
     response.write "<p><a href='Lab5Solution.asp'>Re-enter Year</a></p>"
  
   else
  
     Response.Write "<h2>Year Selected: " & iYear & "</h2>"
          Response.Write "Choose a month below for details:<BR>"
  
     For i = 1 to 12
  
         Response.write "<a href='Lab5Solution.asp?YEAR=" & iYear & "&MONTH=" & i & "&VW=MN'>"
  
         Response.write MONTHNAME(i) & " " & iYear & "</a><BR>"
  
     Next
  
     response.write "<p>&nbsp;</p>"
  
     Response.Write "<a href='Lab5Solution.asp'>Change Year</a><BR>"

      end if

    CASE "MN" 'Month detail
  
     Response.Write "<h2>Month/Year Selected: " & MONTHNAME(iMonth) & " " & iYear & "</h2>"
  
     dtDate = CDATE(iMonth & "/1/" & iYear)
  
     Response.Write "Day of week on first day of month = " & WEEKDAYNAME(WEEKDAY(dtDate)) & "<BR>"
  
     Response.write "<p>&nbsp;</p>"
  
     Response.Write "<a href='Lab5Solution.asp?YEAR=" & iYear & "&VW=YR'>Change Month</a><BR>"
  
     Response.Write "<a href='Lab5Solution.asp'>Change Year</a><BR>"

    CASE ELSE

%>

<form method="POST" action="Lab5Solution.asp">
<p>
Select a Year: <input type="text" name="YEAR" size="4" maxlength="4">
<input type=
"submit" value="Submit">
<input type=
"reset" value="Reset">
<input type=
"hidden" name="VW" value="YR">
</p>
</form>

<%
END SELECT
%>

<hr>
Page footer
</body>
</html>