Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default Date Selection

    Hi,
    I am trying to make a drop down for the user to select the month and date...
    Since Month(1-12) does change through time I have hard coded that... Year
    however does, and I am trying to make this selection dropdown dynamic. My
    attempt so far is to <cfset current_year = DateFormat(Now(),"yyyy")> Which
    =2005 ... Then I am trying to run a loop <CFLOOP CONDITION="current_year LESS
    THAN OR EQUAL TO 2004"> Which is the oldest the date will ever need to be...
    This way in 5 years the drop down will still work... I use this for the loop
    <CFSET current_year = current_year - 1> .....
    However all this isn't working and I can not figure out why.. Any ideas? Or is
    there a better way to go about this? Thank you in advance... I have pasted the
    code below...
    <cfset current_year = DateFormat(Now(),"yyyy")>
    Year:
    <select name="date_y" style="vertical-align: middle">
    <CFLOOP CONDITION="current_year LESS THAN OR EQUAL TO current_year2">
    <option value="current_year">#current_year#</option>
    <CFSET current_year = current_year - 1>
    <CFOUTPUT>#current_year#</CFOUTPUT>
    </CFLOOP>
    </select>

    Boiler2005 Guest

  2. Similar Questions and Discussions

    1. JSObject returns wrong date. How can Iextract correct date from digital signature?
      I'm trying to extract name and date from digital signatures by using JSObject in Excel VBA, but JSObject returns wrong date. Year, month, hour and...
    2. #39245 [NEW]: date function generate wrong date with 1162083600 timestamp
      From: lohner at aldea dot hu Operating system: Linux PHP version: 5.1.6 PHP Bug Type: Date/time related Bug description: ...
    3. a Calendar control with date range selection
      http://cheapdevtools.com/product/product.asp?ProdID=246
    4. a Calendar with date range selection, year navigation
      http://cheapdevtools.com/product/product.asp?ProdID=246
    5. how to refresh page after date selection from popup calendar?
      If you are using window.open to popup the calendar, then before closing the popup you can use 'opener ' handler which gives you the parent page to...
  3. #2

    Default Re: Date Selection

    I hope im understanding this corrently. You want to display now: 2005 and
    2004 in the dropdown Next year you want to display: 2006, 2005, 2004...? Try
    this: <cfset current_year = DateFormat(Now(),'yyyy')> <select name='date_y'
    style='vertical-align: middle'> <CFLOOP CONDITION='#current_year# GTE '2004''>
    <cfoutput> <option value='current_year'>#current_year#</option> </cfoutput>
    <CFSET current_year = current_year - 1> </CFLOOP> </select>

    Vbprog40 Guest

  4. #3

    Default Re: Date Selection

    Boiler2005,

    I was writing this in notepad and did not have a chance to check it... So the
    syntax might be slightly off if my memory didn't serve me correctly.

    <cfset thisyear=#DateFormat(Now(), 'yyyy')#>
    <cfset yearstoshow=5>
    <cfoutput>
    <select name="year" size="1" onChange="document.showdate.submit()">

    <cfset thisyear = #thisyear# - 1>

    <cfloop from="1" to="#yearstoshow#">
    <option value=#thisyear#>#thisyear#</option>
    <cfset thisyear = #thisyear# +1>
    </cfloop>
    </select>
    </cfoutput>

    Will make a drop down showin last year, this year, and the next 3 years. Can
    easily be edited to work for your needs.

    Change: <cfset thisyear = #thisyear# - 1> to subtract the number of years you
    want and <cfset yearstoshow=5> to show a greater range of years.

    -Phil

    Another Phil Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139