i'm trying populate dropdown list month names, 1 days , 1 years , fine except i'm having issues setting month number instead of month name.
this have.
<script> $('document').ready(function() { var minoffset = -70, maxoffset = -17; var thisyear = (new date()).getfullyear(); var m_names = ['january', 'february', 'march','april', 'may', 'june', 'july','august', 'september', 'october','november', 'december']; var month = 0; (var j = month; j <= 11; j++) { var months = m_names[ 0 + j].slice( 0, 3 ); $('<option>', {value: months, text: months}).appendto("#dob_month"); } (var = minoffset; <= maxoffset; i++) { var year = thisyear + i; $('<option>', {value: year, text: year}).appendto("#dob_year"); } }); </script>
the days options hard-coded in form 1-31 (might need populate correct amount of days each month, february being 29).
how can set option value example 01 when january picked?
i open other suggestions besides this. please keep in mind concatenate year-month-day check against date in database.
just change months j+1 on value
like this
$('<option>', {value: j+1, text: months}).appendto("#dob_month");
Comments
Post a Comment