Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CFSelect marks item select but doesnt scroll to selected

Guest
Jun 25, 2010 Jun 25, 2010

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.

422
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 25, 2010 Jun 25, 2010
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources