
Solid, safe website tools.
Whatever your need, Will Bontrager builds powerful software solutions.
|
(Get Attention Ticker for your web site)
Always On Time DropdownsBy Will Bontrager When a form has a dropdown list to select a year, the form creator often extends selections way into the future. For example, a form for this year 2005 might have selections for any year from 2005 through 2015. Recently, I saw a form with a baby's "expected delivery date" dropdown list containing year selections for every year current to 12 years into the future (which observation prompted this article). Now, I realize psychic mothers exist. However, expecting all mothers to be psychic to such an extent could be stretching probabilities just a bit. Maybe whoever created the form just wasn't thinking. Or, more likely, the person didn't want to have to be bothered with maintenance for many years. The maintenance would be adjusting the year numbers in the dropdown list every time a new year rolls around. Using JavaScript, the year numbers in a dropdown list can automatically be adjusted every time a new year rolls around. With that type of automation, the dropdown can contain a reasonable selection. Here is an example: Change the 3 at i <= 3; in the JavaScript to the number of years into the future the dropdown selections shall extend. If you do not want the current year on the list, change the 0 at i = 0; in the JavaScript to 1 (digit 1, not alphabetical "l"). Now, your dropdowns will always be on time. December 24, 2005 Please note: Articles on this website are presented "as is". However - If you have a question about a CGI script, HTML, CSS, PHP, or JavaScript
Rate this blog post.
No page reload! |
|
|
© 1998-2001 William and Mari Bontrager |
|