While working with the date/time input fields in Cake I got tired of having to select 3/6 drop down boxes to choose all of the date/time information and specifically of having to select 3/6 drop down boxes if I decided to clear the date. A little bit of jQuery will clear this right up though.
// Share.on([hacker news,
linkedin,
twitter,
facebook,
reddit])
Just add this this piece of jQuery code and all of your drop down boxes will gain the following behavior:
Now just drop in this jQuery code and you should be good to go.
$('div.input.datetime select').change(function() { if($(this).val() == '') { $(this).siblings('select').val(''); } else { $(this).siblings('select').each(function(sel) { if($(this).val() == '') { if($(this).attr('id').indexOf('Year') != -1) $(this).val((new Date()).getFullYear()); else this.selectedIndex = 1; } }); } });
This article has also been publish at The Bakery.
// Share.on([hacker news,
linkedin,
twitter,
facebook,
reddit])