Set the current year as the default

Posted on 2003-02-25
Medium Priority
Last Modified: 2010-04-06
i have a drop down menu with a number of years in it and i want to set the default year to the current year.
How do i go about this?

my select statement is:

    <b>Year:&nbsp;&nbsp;&nbsp; </b>
            <select name="Year" size="1">
          <option>--Select one--</option>

Question by:alkam
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

Expert Comment

ID: 8015060
u must use the asp functions "now" with the some checks

Accepted Solution

Kovis earned 200 total points
ID: 8015098
function SelectYear() {
 var now = new Date();
<body onLoad="SelectYear()">

You have to add values to your options also:

<option value="2003">2003</option>
<option value="2004">2004</option>

Author Comment

ID: 8015284

Featured Post

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

801 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