[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Current month in a select drop-down to be listed first?

Posted on 2002-03-07
5
Medium Priority
?
319 Views
Last Modified: 2013-12-24
I have a simple select drop-down list, all the "month" options are hard coded.  How can I have the drop-down of months auto populated with the current month listed first, and the next month be the listed next in the drop-down?

This is my current select drop-down:

<SELECT NAME= "CurntDate">
<OPTION VALUE= "01/01/2002">January 2002
<OPTION VALUE= "02/01/2002">February 2002
<OPTION VALUE= "03/01/2002">March 2002
<OPTION VALUE= "04/01/2002">April 2002
<OPTION VALUE= "05/01/2002">May 2002
<OPTION VALUE= "06/01/2002">June 2002
</SELECT>
0
Comment
Question by:cgttsp01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
sshhz earned 200 total points
ID: 6849082
cgttsp01,

You can try in a cfloop, i set it to loop 12 times. You may try to limit to how many times it loop, can get the current month value and minus with total months in a year, and if that is end of the year, what action and data that you're planning to display, and so forth. These must take into considerations. Below is just some simple code to generate current's month onwards till adding 12 more mths in the following.

<cfoutput>
<cfset currentdt = now()>
<SELECT NAME= "CurntDate">
<cfloop index="idx" from="1" to="12">    
 <OPTION VALUE="#DateFormat(currentdt, 'dd/mm/yyy')#">#DateFormat(currentdt, 'mmmm yyyy')#</option>
 <cfset currentdt = DateAdd("m", 1, currentdt)>
</cfloop>
</SELECT>
</cfoutput>

Good Luck.

-sshhz-

0
 
LVL 2

Expert Comment

by:sshhz
ID: 6849086

ops, let me correct this sentence, could interpreted wrongly.

"Below is just some simple code to generate current's month onwards till adding 12 more mths in the following"

What i mean is, after getting current's month value, i add 1 month each of this value, as long as the loop is allow, 12 times. Sorry for my poor english.

-sshhz-
0
 

Author Comment

by:cgttsp01
ID: 6849250
Thank you SSHHZ.
Your code works perfect, and your english is OK.
0
 
LVL 2

Expert Comment

by:sshhz
ID: 6849548
Thank you for the grade and points.

Cheers! :)
0
 

Author Comment

by:cgttsp01
ID: 6850597
sshhz,

Just one more thing on your code.
I noticed when I select a month in its drop-down, that when it actions to the month that is selected, it only shows the selected month an ownward.

I need it to show the current month onward.

For example, if I choose "April 2002" in the drop-down, your code produces that month as the current month in the action page, and does not list the current month anymore.

Can you correct this problem?
Thanks
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question