Reputation: 18103
I have this:
<script>
$(function() {
$( "#datepicker" ).datepicker({
dateFormat : "yy-mm-dd",
onSelect: function(dateText) {
$.post('/admin/deals/booking/',
{ date: dateText }, function(data) {
if(data != '0')
{
$('input[name=book_date]').val(dateText);
$('#results').html(data);
$('.current_text').html(dateText);
$('.book_deal').removeAttr("disabled");
}
});
}
});
$( "#button" ).bind('click', function(){
});
});
</script>
I want when pressing on #button it should activate the above #datepicker, like you have clicked on the date and selected date 2012-02-02
How can this be done?
Upvotes: 0
Views: 2707
Reputation: 53319
According to the docs, datepicker provides is a setDate
method:
$('#datepicker').datepicker('setDate', '2012-02-02')
Upvotes: 1
Reputation: 9158
Instead of
$( "#datepicker" ).datepicker({---});
write
$( "#button" ).datepicker({---});
Upvotes: 0
Reputation: 8503
Have a look at http://jqueryui.com/demos/datepicker/#method-setDate
Upvotes: 1