Reputation: 3
How can I assign the currently selected date instead of new date()
in the following code?
So from here each time when I refresh, it will give me currently selected date in textbox instead of becoming blank
$(".date-pick").datepicker('setDate', new Date());
Upvotes: 0
Views: 141
Reputation: 2208
try this ..
use onclose event of datepicker to set the value of date .... "$(this).val()" this will have the value of currently selected date and set this value to Html Element using "document.getElementsByClassName('.date-pick').value"
$( ".date-pick" ).datepicker({
onClose: function(dateText, inst) {
document.getElementsByClassName('.date-pick').value= $(this).val();
}
});
Upvotes: 1