Return to v1.4.5 docs

yearSelectTag()



Builds and returns a string containing a select form control for a range of years based on the supplied name.

Name Type Required Default Description
name string Yes See documentation for textFieldTag.
selected string No The year that should be selected initially.
startYear numeric No 2010 See documentation for dateSelect.
endYear numeric No 2020 See documentation for dateSelect.
includeBlank any No false See documentation for select.
label string No See documentation for textField.
labelPlacement string No around See documentation for textField.
prepend string No See documentation for textField.
append string No See documentation for textField.
prependToLabel string No See documentation for textField.
appendToLabel string No See documentation for textField.
<!--- View code --->
<cfoutput>
    #yearSelectTag(name="yearOfBirthday", selected=params.yearOfBirthday)#
</cfoutput>

<!--- Only allow selection of year to be for the past 50 years, minimum being 18 years ago --->
<cfset fiftyYearsAgo = Now() - 50>
<cfset eighteenYearsAgo = Now() - 18>
<cfoutput>
	#yearSelectTag(name="yearOfBirthday", selected=params.yearOfBirthday, startYear=fiftyYearsAgo, endYear=eighteenYearsAgo)#
</cfoutput>