views:

5874

answers:

9

I'm in search of a JavaScript month selection tool. I'm already using jQuery on the website, so if it were a jQuery plugin, that would fit nicely. I'm open to other options, as well.

Basically, I'm after a simplified version of the jQuery UI Date Picker. I don't care about the day of the month, just the month and year. Using the Date Picker control feels like overkill and a kludge. I know I could just use a pair of select boxes, but that feels cluttered, and then I also need a confirmation button.

I'm envisioning a grid of either two rows of six columns, or three rows of four columns, for month selection, and current and future years across the top. (Maybe the ability to list a few years? I can't see anyone ever needing to go more than a year or two ahead, so if I could list the current and next two years, that would be swell)

It's really just a dumbed down version of the DatePicker. Does something like this exist?

+1  A: 

Sorry for not providing a finished solution. But you say "I don't care about the day of the month, just the month and year", which fits perfectly to the experimental "maximum 2 clicks jQuery timepickr plugin". Maybe you can modify this plugin so, that you can select month and year instead of hour and minutes?

jk
Not a bad idea, but I don't think it will be a fit for this website. Thanks, though.
Adam Tuttle
+3  A: 

I used this script in a program a while back. While it is ancient, it works on all browsers well. If you look down to "Month-select calendar" I believe that is what you are looking for. The example that is there has the calendar opening in a new window (ew) but 1 setting (like the 2nd example) makes it show ala jQuery. Good luck.

Paolo Bergantino
+1  A: 

I just had a pick a date picker the other day. I found two other interesting examples that might help you out, but I'm not sure how you are going to do this without showing the calendar. Most "date pickers" just assume you are going to want to see a calendar. You might do better to look for a custom dropdown that has some custom buttons you can configure.

Here are the ones I looked at:

http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/index.html

I ended up using this one: http://jqueryui.com/demos/datepicker/

If you are any good with JQuery, you might have come up with a good little project.

jj
+1  A: 

I've been looking into jquery datepickers extensively, and I don't think you'll find a packaged solution... :(

However, what you may be able to do, if I'm reading you right, is make an html list of months, float them menue-ish style, and make them selectable values with jQuery.

Again, I'm not totally sure exactly how you want things to operate, but this would be a simple solution w/o bloat. :)

Does that make a little sense to you? (it does to me, but often times what I think doesn't translate to others)

Kevin Brown
+2  A: 

Have a look at this link: http://project.yctin.com/monthpicker/demo/. I think it does what your looking for.

Yeah, that's the data I'm after; but the UI is enormous (and ugly). Thanks, though.
Adam Tuttle
A: 

I'm after the exact same thing. The month picker listed above comes close, but it is quite kludgy. It would be nice to have something that looks and behaves like jQueryDatePicker, but with the option to pick months rather than days...

The monthpicker author seems responsive to user feedback and I added a request for DatePicker-esque behavior. I'll post an update here if he comes through!

Victor Van Halen
+1  A: 

Ben Koehler from this equivalent question offers a jquery ui hack that works decently. Quoted here for convenience, all credit is his.

-- Here's a hack (updated with entire .html file):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.js"&gt;&lt;/script&gt;
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"&gt;&lt;/script&gt;
    <link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css"&gt;
<script type="text/javascript">
$(function() {
    $('.date-picker').datepicker( {
        changeMonth: true,
        changeYear: true,
        showButtonPanel: true,
        dateFormat: 'MM yy',
        onClose: function(dateText, inst) { 
            var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
            var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
            $(this).datepicker('setDate', new Date(year, month, 1));
        }
    });
});
</script>
<style>
.ui-datepicker-calendar {
    display: none;
    }
</style>
</head>
<body>
    <label for="startDate">Date :</label>
    <input name="startDate" id="startDate" class="date-picker" />
</body>
</html>
Cory
A: 

This might work for you: http://project.yctin.com/monthpicker/demo/ Looks a bit ugly, but all you need is a bit of CSS to make it look right.

And this one is pretty nice, and might be used as a year/month picker with some callback hackery: http://www.eyecon.ro/datepicker/

Infinity
A: 

I needed similar functionality and decided to go with Cory's (Ben Koehler's) answer.

Dodecapus