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

(12-21-2015, 04:31 AM)sintakonte Wrote: you should do this via javascript - it doesn't have much to do with CI, i think
if you use jquery you can try something like this (untested just wrote it down)

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++)
        {
            $('select[name="day"]).append($("<option></option>").attr("value",i).text(i);
        }

    }
});

Not work did not display any days.
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, 04:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB