简体   繁体   中英

Date Pick Day Month Year

http://keith-wood.name/datepick.html

but the only thing i can see is fetch an alert of the whole time day month

$(function() {
    $('#popupDatepicker').datepick();
    $('#inlineDatepicker').datepick({onSelect: showDate});
});

function showDate(date) {
    alert('The date chosen is ' + date);
}

i want to know how do i make them split up to like

<input type="text" name="date" id="popupDatepicker"> When i select date here the fields in the hidden will change below
<input type="hidden" name="day">
<input type="hidden" name="month">
<input type="hidden" name="year">

Please advise

The problem with the date picker's onselect handler is that passes the date as a string using whatever format you've put onto the date picker.

You can use $('#inlineDatepicker').datepicker('getDate') to get an actual Date object representing the selected date.

You can also use $.datepicker.formatDate() to convert that object into alternative string formats, or use the Date object's own methods to extract the numeric values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM