Skip to content

Miscellaneous

yearSelectTag()

yearSelectTag() — returns any

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

NameTypeRequiredDefaultDescription
namestringyes—See documentation for textFieldTag.
selectedstringyes—The year that should be selected initially.
startYearnumericyes2010See documentation for dateSelect.
endYearnumericyes2020See documentation for dateSelect.
includeBlankanyyesfalseSee documentation for select.
labelstringyes—See documentation for textField.
labelPlacementstringyesaroundSee documentation for textField.
prependstringyes—See documentation for textField.
appendstringyes—See documentation for textField.
prependToLabelstringyes—See documentation for textField.
appendToLabelstringyes—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>