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

Reply

Join Date: Sep 2004
Posts: 7
Reputation: jchamel is an unknown quantity at this point 
Solved Threads: 0
jchamel's Avatar
jchamel jchamel is offline Offline
Newbie Poster

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

 
0
  #1
Oct 9th, 2004
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
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 10
Reputation: Cyber-SEO is an unknown quantity at this point 
Solved Threads: 0
Cyber-SEO Cyber-SEO is offline Offline
Newbie Poster

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

 
0
  #2
Oct 10th, 2004
The problem is here:

You have:
  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:
  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. %>
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 166
Reputation: Lafinboy is an unknown quantity at this point 
Solved Threads: 7
Lafinboy's Avatar
Lafinboy Lafinboy is offline Offline
Junior Poster

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

 
0
  #3
Oct 10th, 2004
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:

  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. %>
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 ::

Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7
Reputation: jchamel is an unknown quantity at this point 
Solved Threads: 0
jchamel's Avatar
jchamel jchamel is offline Offline
Newbie Poster

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

 
0
  #4
Oct 13th, 2004
[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!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC