?
Solved

Set the current year as the default

Posted on 2003-02-25
3
Medium Priority
?
154 Views
Last Modified: 2010-04-06
Hi
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>
          <option>2003</option>
          <option>2004</option>
          <option>2005</option>
          <option>2006</option>
          <option>2007</option>
          <option>2008</option>
          <option>2009</option>
          <option>2010</option>
          <option>2011</option>
          <option>2012</option>
          <option>2013</option>
          <option>2014</option>
          <option>2015</option>
          <option>2016</option>
          <option>2017</option>
          <option>2018</option>
          <option>2019</option>
          <option>2020</option>
     </select>

0
Comment
Question by:alkam
[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 Comments
 

Expert Comment

by:randhawa
ID: 8015060
u must use the asp functions "now" with the some checks
0
 
LVL 2

Accepted Solution

by:
Kovis earned 200 total points
ID: 8015098
<script>
function SelectYear() {
 var now = new Date();
 Year.value=now.getYear();
}
</script>
<body onLoad="SelectYear()">

You have to add values to your options also:

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

Author Comment

by:alkam
ID: 8015284
perfect!
cheers
0

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