| | |
selection problem in a month loop
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Feb 2008
Posts: 174
Reputation:
Solved Threads: 3
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).
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).
ASP Syntax (Toggle Plain Text)
<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 3:11 pm.
![]() |
Similar Threads
Other Threads in the ASP Forum
- Previous Thread: inserting pictures in oracle using ASP
- Next Thread: ASP To Access
Views: 929 | Replies: 0
| Thread Tools | Search this Thread |
Tag cloud for ASP
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection calendar changeable connection current database databaseconnection diagnostics dreamweaver excel fso html iis microsoft msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile query record searchbox selectoption server single specfic sqlserver sqlserverconnection toolkit update web webserver windows7





