Create dropdown selection for last 12 months.

Simple Coldfusion method for creating a select dropdown form element of the last 12 months sorted descending. The report-date is formatted for oracle queries. Change the dateFormat mask to fit your needs.


<cfselect name="report_date">
<cfloop from="1" to="12" index="x" step="1">
<cfset xMonth = dateAdd("m", -1 * x, now())>
<cfoutput>
<option value="1-#dateFormat(xMonth,'mmm-yyyy')#">1-#dateFormat(xMonth,"mmm-yyyy")#</option>
</cfoutput>
</cfloop>
</cfselect>

Cup size   
Select size then click on coffee cup.
This entry was posted in Code. Bookmark the permalink.