so_createDateDropDown | JavaScriptSource


Steve Chipman Jul 2, 2008


Returns a select element object with dates from the current date either into the past or the future based on the value of the direction argument. Easy to add to any form.



Integer numDays
The number of days from today to include in the select element.
Integer direction
Determines if days are counted forward of backward. 0 for forward, 1 for backwards.

This creates a select element with dates up to ten days in the future:

var dateSelectObject = so_createDateDropDown(10,0);

In the spirit of unobtrusive scripting and progressive enhancement, it is recommended that you provide a fallback means to this element should the user not have JavaScript available. A simple example would be a hard-coded text input that the user can type their data in which would be replaced by this dynamically created element.

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: createDateDropDown.js


Paste this code into the HEAD section of your HTML document.


Paste this code into the BODY section of your HTML document

Leave a Response