jQuery Year, Half Year and Quarter year picker -



jQuery Year, Half Year and Quarter year picker -

i'm looking jquery plugin pick

year (no months , dates) [i can pretty much utilize regular drop downwards this] half year - 1st half , 2nd half (half yearly) eg. jan -jun, 2010; jul dec, 2010 quarter year - 1st quarter, 2nd quarter, 3rd quarter, 4th quarter eg. jan-mar, 2010; apr-jun, 2010 etc.

is there such plugin or how edit regular jquery date-picker accomplish this?

yeah, using select boxes choice, think, because simple solutions.

then can have html file looking this:

index.html:

<!doctype html> <html> <head> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"> </script> <script src="picker.js"></script> <script> $(function() { $('#year').yearpicker(); $('#halfyear').halfyearpicker(); $('#quarteryear').quarteryearpicker(); }); </script> </head> <body> <p> year:<br> <select id="year"></select> </p> <p> halfyear:<br> <select id="halfyear"></select> </p> <p> quarteryear:<br> <select id="quarteryear"></select> </p> </body> </html>

picker.js:

$.fn.extend( { yearpicker: function() { var select = $(this); var year = new date().getfullyear(); (var = -10; < 11; i++) { var alternative = $('<option/>'); var year_to_add = year + i; option.val(year_to_add).text(year_to_add); if (year == year_to_add) { alternative .css('font-weight', 'bold') .attr('selected', 'selected'); } select.append(option); } }, halfyearpicker: function() { var select = $(this); var date = new date(); var year = date.getfullyear(); var half = math.floor(date.getmonth() / 6); (var = -10; < 11; i++) { var year_to_add = year + i; (var j = 0; j < 2; j++) { var alternative = $('<option/>'); var half_text = j == 0 ? 'jan-jun' : 'jul-dec'; var value = year_to_add + '-' + (j + 1); var text = year_to_add + ' ' + half_text; option.val(value).text(text); if (year_to_add == year && half == j) { alternative .css('font-weight', 'bold') .attr('selected', 'selected'); } select.append(option); } } }, quarteryearpicker: function() { var select = $(this); var date = new date(); var year = date.getfullyear(); var quarter = math.floor(date.getmonth() / 3); (var = -10; < 11; i++) { var year_to_add = year + i; (var j = 0; j < 4; j++) { var alternative = $('<option/>'); var quarter_text = get_quarter_text(j); var value = year_to_add + '-' + (j + 1); var text = year_to_add + ' ' + quarter_text; option.val(value).text(text); if (year_to_add == year && quarter == j) { alternative .css('font-weight', 'bold') .attr('selected', 'selected'); } select.append(option); } } function get_quarter_text(num) { switch(num) { case 0: homecoming 'jan-mar'; case 1: homecoming 'apr-jun'; case 2: homecoming 'jul-sep'; case 3: homecoming 'oct-dec'; } } } });

jquery

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -