944,196 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 11160
  • ASP RSS
Oct 9th, 2004
0

Do while Loop to display a choosen month and the dates in it

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jchamel is offline Offline
7 posts
since Sep 2004
Oct 10th, 2004
0

Re: Do while Loop to display a choosen month and the dates in it

The problem is here:

You have:
ASP Syntax (Toggle Plain Text)
  1. <%
  2. varRowCount = 1
  3. varTodayDate = day(now())
  4. varTodayMonth = MonthName(month(date())
  5. Response.Write "<h2>Report for " & varTodayMonth & "</h2>"
  6. Do While varMonthCount <32 or <= 31
  7. Response.Write "The days of " & varTodayMonth & " " & varRowCount
  8. Response.Write ": are varTodayDate<br>"
  9. varRowCount = varRowCount + 1
  10. Loop
  11. %>

It should be:
ASP Syntax (Toggle Plain Text)
  1. <%
  2. varRowCount = 1
  3. varTodayDate = day(now())
  4. varTodayMonth = MonthName(month(date())
  5. Response.Write "<h2>Report for " & varTodayMonth & "</h2>"
  6. Do While varMonthCount <32 or varMonthCount <= 31
  7. Response.Write "The days of " & varTodayMonth & " " & varRowCount
  8. Response.Write ": are varTodayDate<br>"
  9. varRowCount = varRowCount + 1
  10. Loop
  11. %>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Cyber-SEO is offline Offline
10 posts
since Sep 2004
Oct 10th, 2004
0

Re: Do while Loop to display a choosen month and the dates in it

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)
  1. <form>
  2. <select size="1" name="Month">
  3. <option value="January">Jan</option>
  4. <option value="February">Feb</option>
  5. <option value="March">Mar</option>
  6. <option value="April">Apr</option>
  7. <option value="May">May</option>
  8. <option value="June">Jun</option>
  9. </select>
  10. <input type="submit" value="Choose Month">
  11. </form>
  12. <%
  13. dim intDay '// incremental number used in the loop
  14. dim daysInMonth '// the number of days in each month
  15. dim strMonth '// the selected month
  16.  
  17. intDay = 1 '// set the value to 1 to start
  18. strMonth = request("month") '// set the month to the one selected in the form
  19.  
  20. If strMonth <> "" Then '// If a month has been selected display the results
  21.  
  22. '// assign the number of days to each month
  23. Select Case strMonth
  24. Case "January", "March", "May", "July", "August", "October", "December"
  25. daysInMonth = 31
  26. Case "February"
  27. daysInMonth = 28
  28. Case Else
  29. daysInMonth = 30
  30. End Select
  31.  
  32. '// Display the total number of days in the selected month
  33. Response.Write "The days of " & strMonth & " are "
  34. '// Then loop through the days in the month, starting at 1
  35. Do While intDay <= daysInMonth
  36. Response.Write intDay & ", "
  37. intDay = intDay + 1
  38. Loop
  39.  
  40. Else '// there has been no month selected so....
  41. ' do nothing
  42. End If
  43. %>
Reputation Points: 16
Solved Threads: 7
Junior Poster
Lafinboy is offline Offline
166 posts
since Jul 2004
Oct 13th, 2004
0

Re: Do while Loop to display a choosen month and the dates in it

[QUOTE=Lafinboy]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:

Thanks so much you have been so much help to me. YOUR GREAT!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jchamel is offline Offline
7 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: HELP -my Date code isnt working
Next Thread in ASP Forum Timeline: simple calculations How? intHrlyRate, etc Help me





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC