0

こんなシチュエーションがありますが、

for( int i=0; i < 5; i++)
{
    <input type="text" id="t"+i val=""/>
}

すべてのテキスト ボックスに日付ピッカーが必要です...どのように..?

ページ読み込み時に可能ですか..?

私はこのようにしてみました、、

日付を選択した後、尊重されたテキストボックスに設定する必要があります

for( int i=0; i < 5; i++)
{
    <input type="text" id="t"+i val=""/>
    <input type="hidden" id="h"+i val=""/>
}



<script>
$(function () {
    var updateValue = false;
    $('input:hidden[id^=h]').datepicker({
        showOn: 'button',
        buttonText: 'Open calendar',
        buttonImageOnly: true,
        buttonImage: '/imagesOnline/calendar.png',
        dateFormat: 'dd/mm/yy',

        changeYear: atrue,
        changeMonth: true,
        onSelect: function (dateText, inst) {
            //how to set respected text field
            $('#ExpireDate').val(dateText);
        }
    });
    //Animate datepicker
    $("#AssignedPartnerOrgHidden1").datepicker("option", "showAnim", "show");

    //pointer mark on mouseover
    $(".ui-datepicker-trigger").mouseover(function () {
        $(this).css('cursor', 'pointer');
    });

});
</script>
4

5 に答える 5

0

$('input:text[id^=t]')inputtypetextを持ち、次でid始まるすべての要素を選択しますt

$('input:text[id^=t]').datepicker();

属性を含むセレクター

^セレクターで始まる属性

OPが質問を更新した後に更新

onSelect: function (dateText, inst) {
            var id = this.id.replace('h','');
            $('#t'+id).val(dateText);
        }
于 2013-09-11T07:01:43.200 に答える
0

それにクラスを与えます..入力が追加された後、datepickerを再度初期化します

 <input type="text" id="t"+i class="dynamicInput" val=""/>

追加された後にこれを呼び出します

//code for inserting the input
$('.dynamicInput').datepicker();

クラスなしで属性セレクターを使用できます

$('input[id^=t]').datepicker();
于 2013-09-11T07:02:03.340 に答える
0

Jquery datepicker プラグインを見てください。

http://jqueryui.com/datepicker/を参照

これは、作成中の input タグまたは既存の onces にバインドできます。

いくつかの簡単なコード

<script>
    $("#datepicker").datepicker();
</script>

<html><input type="text" id="datepicker" />
于 2013-09-11T07:02:54.030 に答える
0
<input class="datepicker">
<input class="datepicker">
<input class="datepicker">
<input class="datepicker">
<input class="datepicker">
or 
for( int i=0; i < 5; i++)
{
    <input type="text" class = "datepicker " val=""/>
}
$('.datepicker').datepicker();
于 2013-09-11T09:27:49.620 に答える