Copy link to clipboard
Copied
I have a list of dates from the a database and they list like:
August 2009
September 2009
all the way to like
Decemeber 2011.
As a new project may be added for Jan 2012 it would go to the bottom of the list.
What I want to do is have the current month selected and at the top of my combo box. The month is being selected but I have to scroll to it. Here is my code.
<cfset myYear=DateFormat(Now(), "yyyy")>
<cfset myMonthName=DateFormat(Now(), "mmmm")>
<cfset myMonth=DateFormat(Now(), "m")>
<cfselect name="month" class="multiSelect" multiple="yes" size="5" >
<cfoutput query="Dates" >
<option value="#assignMonth#--#assignYear#" <cfif #assignMonth# EQ #myMonth# and #assignYear# EQ #myYear#>selected</cfif>>#monthName# #assignYear#</option>
</cfoutput>
</cfselect>
Any ideas? Thanks in advance.
Copy link to clipboard
Copied
make your dates query resemble this:
select current_year_month ym, 1 sortkey
from etc
union
select other_year_months ym, 2 sortkey
from etc
order by sortkey, ym
Then you won't even need a selected attribute in your cfselect.