views:

490

answers:

2

I need to be able to grab the selected date from the datepicker and populate another textbox with the selected value. I am currently using the onClose function like this:

        $('#defaultDate').datepicker({
          onClose:function(theDate) {
            $('#txtEntry1').text = theDate
        }
        });
+1  A: 

There's an easier way to do it. Use the built-in alt-field option and you're done.

Matt Ball
Perfect, thanks!
Matt
+1  A: 

Have you looked through the docs? http://docs.jquery.com/UI/Datepicker#events

onSelect function(dateText, inst)

Allows you to define your own event when the datepicker is selected. The function receives the selected date as text and the datepicker instance as parameters. this refers to the associated input field. Code examples

Supply a callback function to handle the onSelect event as an init option.

$('.selector').datepicker({
   onSelect: function(dateText, inst) { ... }
});
Thomas Ahle