Welcome Guest, Not a member yet? Register   Sign In
[Solved] Populate select dropdown with correct number of days when select month.
#9

(12-21-2015, 04:58 AM)sintakonte Wrote: no offense but you should've found the typos in the script by yourself

Code:
$('select[name="month"]').on("change", function()
{
    var year = $('select[name="year"]').val();
    if (year > 0)
    {
        $('select[name="day"]').find("option").remove();
        var daysInMonth = new Date(year, $(this).val(), 0).getDate();
        for(var i=1; i<=daysInMonth;i++)
        {
            console.log(i);
            $('select[name="day"]').append($("<option></option>").attr("value",i).text(i));
        }

    }
});

Thank you for help I have had to add

Code:
$( document ).ready(function() {


});

And it worked.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
RE: Populate select dropdown with correct number of days when select month. - by wolfgang1983 - 12-21-2015, 05:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB