I have a HTML page with 3 dropdowns for the month, day and year and I was wondering if there was a way to populate the month drop down properly depending on the month and year.
I haven't done this before on the client side, but it looks like a lot of controls like the jQuery DatePicker are doing that behind the scenes.
You can actually use this:
var curdate = new Date(); DaysMonth = 32 - new Date(curdate.getYear(), curdate.getMonth(), 32).getDate();
;)
As far as I know, there's no (neat) built-in function for that. I wrote this once:
I am using this approach in my current project and found that I needed correct for round off errors. So instead of using monthLength in my code, I had to use this instead:
For example if I have an object in which I am storing a text date field, it may look like this:
Here's the one liner. Assuming you are saying January=1, February=2 etc..(being normal) Here's the leap year example: