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
namestringyesSee documentation for textFieldTag.
selectedstringyesThe year that should be selected initially.
startYearnumericyes2010See documentation for dateSelect.
endYearnumericyes2020See documentation for dateSelect.
includeBlankanyyesfalseSee documentation for select.
labelstringyesSee documentation for textField.
labelPlacementstringyesaroundSee documentation for textField.
prependstringyesSee documentation for textField.
appendstringyesSee documentation for textField.
prependToLabelstringyesSee documentation for textField.
appendToLabelstringyesSee 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>