Jul
04
2002
Filling a list with months
Posted by admin under
Daterelated functions
<%
Sub Date_FillBoxWithMonths( nDefault, fUseNumbersAsValue )
Dim nMonth
If nDefault = "" Then
nDefault = Date_GetMonthNo( Now() )
End If
For nMonth = 1 To 12
Response.Write "<option"
If nMonth = nDefault Then
Response.Write " selected=yes"
End If
If fUseNumbersAsValue = True Then
Response.Write " value=" & nMonth
End If
Response.Write ">" & Date_GetMonthName(nMonth) & "</option>"
Next
End Sub
%>
Fills a listbox with month names. nDefault tells which year should be preselected. If fUseNumberAsValue is true then a number is used as a value instead of the month name text.
Usage:
<select size="1" name="FromMonth">
<% Date_FillBoxWithMonths Date_GetMonthNo( Now() ), True %>
</select>