Skip to content Skip to sidebar Skip to footer

Changing The Format Of Jquery Ui's Datepicker Breaks Synchronisation With A Select List

Thanks to techfoobar, I have a datepicker with a synchronised input field and a select list. However, when I have changed the format of the date to 'yy-mm-dd', it stopped working.

Solution 1:

The value you are trying to select in the select element does not exist, because the substring yields a different value than it originally did. You need to adjust your substr accordingly.

functionupdateSelected() {
    var date1 = $(this).val();

    console.log(date1.substring(8));
    console.log(date1.substring(0, 4));

    $('#selectDay').val(date1.substring(8));
    $('#selectYear').val(date1.substring(0, 7));
}

jsfiddle

Post a Comment for "Changing The Format Of Jquery Ui's Datepicker Breaks Synchronisation With A Select List"