User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 427,200 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,274 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 595 | Replies: 0 | Solved
Reply
Join Date: Feb 2008
Posts: 135
Reputation: TobbeK is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
TobbeK TobbeK is offline Offline
Junior Poster

selection problem in a month loop

  #1  
Mar 15th, 2008
I have a small problem with this select box.

This one loops out [year-month] in 12 month periods starting from the current month. When a selection has been done, a month value is sended back to this select box so that the selected month then stays selected. That works, as long as the current month is NOT bigger than the ending month. If it's equal or bigger then it works.

Example:
--------------
2008-03 (Equal month as the ending month)
2008-04
2008-05
2008-06
2008-07
2008-08
2008-09
2008-10
2008-11
2008-12
2009-01 (Problem)
2009-02 (Problem)
2009-03 (Equal month as the starting month)

A value from the example cannot be used if the month value is smaller than the current month (2008-03).


<select name="ymvalue" class="usermenuform" size="1" onchange="ymform.submit()">
<option value="0">- year / month -</option>

<%

Session("ym") = Request.Form("ymvalue")

YM = Session("ym")
a = date()


If YM <> "" Then
 	If YM > "0" Then

x = 1
For i = DatePart("m",a) To DatePart("m",Session("ym"))
x = x +1
Response.Write("<option value=" & Year(a)&"-"&Right("0" & Month(a),2) & " SELECTED >" & Year(a)&"-"&Right("0" & Month(a),2) & "-</option>")
a = DateAdd( "m", 1, a )
Next

x = x -1

For i = 0 To 12 -x
Response.Write("<option value=" & Year(a)&"-"&Right("0" & Month(a),2) & ">" & Year(a)&"-"&Right("0" & Month(a),2)  & "-</option>")
a = DateAdd( "m", 1, a )
Next

	End If
End If


If YM = "" OR YM = "0" Then

For i = 0 To 12
Response.Write("<option value=" & Year(a)&"-"&Right("0" & Month(a),2) & ">" & Year(a)&"-"&Right("0" & Month(a),2)  & "-</option>")
a = DateAdd( "m", 1, a )
Next
End If

%>

</select>
Last edited by TobbeK : Mar 15th, 2008 at 2:11 pm.
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP Forum

All times are GMT -4. The time now is 10:39 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC