Solved

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

Posted on 2002-03-07
5
288 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 50 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

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…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 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