5

Datepicker から選択した日付を取得し、選択した値を別のテキスト ボックスに入力できるようにする必要があります。現在、次のonCloseような関数を使用しています。

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

2 に答える 2

12

もっと簡単な方法があります。組み込みのalt-field オプションを使用すれば完了です。

altFieldおよびaltFormatオプションを使用して日付が選択されるたびに、代替フィールドに独自の日付形式を入力します。この機能を使用して、ユーザーが選択できるように人間にわかりやすい日付を提示し、さらに処理するためにコンピューターにわかりやすい日付を渡すことができます。

于 2010-02-22T14:56:58.627 に答える
6

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) { ... }
});
于 2010-02-22T14:58:13.590 に答える