Thursday, April 8, 2010

Populate Date DropDown using Javascript

Set the values of Dropdown list of a date:-

There are three dropdown lists for each Day, Month And Year.  we fill through javascript with following way:

        var date ="11/23/2010"; //Format- MM/DD/YYYY
        var mm = date.substring(0,2);
        var dd = date.substring(3,5);
        var yy = date.substring(6,10);
       
        document.getElementById("ddlDay").value=dd;
        document.getElementById("ddlMonth").value=mm;
        document.getElementById("ddlYear").value=yy;

No comments: