Setting a particular date using Jquery

lakesh picture lakesh · Aug 8, 2012 · Viewed 7.2k times · Source

I am using mobiscroll.js and am trying to set a particular date like 14/06/2005. This is my senior's code. I am not sure how to edit to set a particular date.

Code:

(function ($) {
    var date = new Date();
    $("#id_childbirthday").scroller({mode: 'clickpick',
        dateOrder: 'ddMyyyy',
        dateFormat: 'dd M yyyy',
        endYear: date.getFullYear() - 7,
        startYear: 1990});
})(jQuery);

The image looks like this:enter image description here

I can set the year to the year i want... But how to edit this code to get it outputting a particular date... Need some guidance...

Answer

David Hedlund picture David Hedlund · Aug 8, 2012

According to the docs, your mobiscroll instance has a setValue method.

The syntax appears to be:

$('#id_childbirthday').scroller('setValue', data, true);

... where data is an array of values, matching the order of the wheels.