| | |
Do while Loop to display a choosen month and the dates in it
Please support our ASP advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
Here is my code. As always I don't understand what beginning asp 3.0 . The book says to do this code, but doesn't explain what vartodaymonth means or varTodayDate = day(now()) means. I am suppose to make two files one html file and in it have the months of the year and only one month should be passed on to the asp page. Not sure how to do that? In that page all of the days of the month I choose should be displayed Like this
The days of ____ are 1
The days of ____ are 2 etc.
In that blank should be the month I chose to use.
Here is all I can come up with using the book beginning active server pages 3.0 p 195 if you know this book.
<html>
<head>
<title>Example Do While</title>
</head>
<body>
<H1>This is the days of January</H1>
<%
varRowCount = 1
varTodayDate = day(now())
varTodayMonth = MonthName(month(date())
Response.Write "<h2>Report for " & varTodayMonth & "</h2>"
Do While varMonthCount <32 or <= 31
Response.Write "The days of " & varTodayMonth & " " & varRowCount
Response.Write ": are varTodayDate<br>"
varRowCount = varRowCount + 1
Loop
%>
</body>
</html>
The book says this will display if requested on the ninth of september.
How do I get it to display the month of January and say
The days of January are 1
The days of Januray are 2
and so on
If anyone knows of another book that explains asp code to a beginner with examples please let me know
The days of ____ are 1
The days of ____ are 2 etc.
In that blank should be the month I chose to use.
Here is all I can come up with using the book beginning active server pages 3.0 p 195 if you know this book.
<html>
<head>
<title>Example Do While</title>
</head>
<body>
<H1>This is the days of January</H1>
<%
varRowCount = 1
varTodayDate = day(now())
varTodayMonth = MonthName(month(date())
Response.Write "<h2>Report for " & varTodayMonth & "</h2>"
Do While varMonthCount <32 or <= 31
Response.Write "The days of " & varTodayMonth & " " & varRowCount
Response.Write ": are varTodayDate<br>"
varRowCount = varRowCount + 1
Loop
%>
</body>
</html>
The book says this will display if requested on the ninth of september.
How do I get it to display the month of January and say
The days of January are 1
The days of Januray are 2
and so on
If anyone knows of another book that explains asp code to a beginner with examples please let me know
•
•
Join Date: Sep 2004
Posts: 10
Reputation:
Solved Threads: 0
The problem is here:
You have:
It should be:
You have:
ASP Syntax (Toggle Plain Text)
<% varRowCount = 1 varTodayDate = day(now()) varTodayMonth = MonthName(month(date()) Response.Write "<h2>Report for " & varTodayMonth & "</h2>" Do While varMonthCount <32 or <= 31 Response.Write "The days of " & varTodayMonth & " " & varRowCount Response.Write ": are varTodayDate<br>" varRowCount = varRowCount + 1 Loop %>
It should be:
ASP Syntax (Toggle Plain Text)
<% varRowCount = 1 varTodayDate = day(now()) varTodayMonth = MonthName(month(date()) Response.Write "<h2>Report for " & varTodayMonth & "</h2>" Do While varMonthCount <32 or varMonthCount <= 31 Response.Write "The days of " & varTodayMonth & " " & varRowCount Response.Write ": are varTodayDate<br>" varRowCount = varRowCount + 1 Loop %>
Or you can make it a bit more dynamic by allowing the user to select the month and then display the days in that month, as below:
ASP Syntax (Toggle Plain Text)
<form> <select size="1" name="Month"> <option value="January">Jan</option> <option value="February">Feb</option> <option value="March">Mar</option> <option value="April">Apr</option> <option value="May">May</option> <option value="June">Jun</option> </select> <input type="submit" value="Choose Month"> </form> <% dim intDay '// incremental number used in the loop dim daysInMonth '// the number of days in each month dim strMonth '// the selected month intDay = 1 '// set the value to 1 to start strMonth = request("month") '// set the month to the one selected in the form If strMonth <> "" Then '// If a month has been selected display the results '// assign the number of days to each month Select Case strMonth Case "January", "March", "May", "July", "August", "October", "December" daysInMonth = 31 Case "February" daysInMonth = 28 Case Else daysInMonth = 30 End Select '// Display the total number of days in the selected month Response.Write "The days of " & strMonth & " are " '// Then loop through the days in the month, starting at 1 Do While intDay <= daysInMonth Response.Write intDay & ", " intDay = intDay + 1 Loop Else '// there has been no month selected so.... ' do nothing End If %>
If I've been a help please confirm by clicking the Add to Lafinboy's Reputation link in the header of this reply.
Lafinboy Productions
:: Website Design :: Website Development ::
Lafinboy Productions
:: Website Design :: Website Development ::
![]() |
Similar Threads
- Using a loop to display the characters for ACSII codes? HELP! (C++)
- Loan repayment calculator (Java)
- while loop!!!! dont know how to do it??? (Java)
- Code w/in for loop to display only certain characters (C++)
Other Threads in the ASP Forum
- Previous Thread: HELP -my Date code isnt working
- Next Thread: simple calculations How? intHrlyRate, etc Help me
| Thread Tools | Search this Thread |
archive asp aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection connection database databaseconnection dreamweaver excel fso msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption single specfic sqlserver sqlserverconnection





