Skip to main content
Known Participant
August 18, 2009
Answered

Dynamic Year Select Box

  • August 18, 2009
  • 1 reply
  • 679 views

I would like to make a select box that has the last 50 years in it.  I want it to change with each year instead of me going in and changing it in the code. Would I do this with an array? I think there is an easy way to do this but I can not figure it out.

Thanks for your help

    This topic has been closed for replies.
    Correct answer Dan_Bracuk

    <cfoutput>

    <cfset theyear = year(now())>

    <select name = year>

    <cfloop from = "1" to = "50" index = "i">

    <option value = "#theyear# />#theyear#

    <cfset theyear = theyear - 1>

    closing tags

    1 reply

    Dan_BracukCorrect answer
    Inspiring
    August 18, 2009

    <cfoutput>

    <cfset theyear = year(now())>

    <select name = year>

    <cfloop from = "1" to = "50" index = "i">

    <option value = "#theyear# />#theyear#

    <cfset theyear = theyear - 1>

    closing tags

    Rcain37Author
    Known Participant
    August 19, 2009

    Thanks for the help.  Thats exactly what I needed.