0

ドロップダウン (値は 1, 2, 3 ) とテキスト ボックスを備えた ASP.NET Repeater コントロールがあります。したがって、コードの複数のインスタンスが、ドロップダウンとテキスト ボックスを使用して各 ItemTemplate で生成/作成されます。

jQuery/javascript で関数を作成しようとしています。ドロップダウンの値が 1 に選択されるたびに、テキスト ボックスを無効にする必要があります。これで、このドロップダウンは、1 番目、3 番目、または 5 番目の誰でも指定できるようになり、それぞれのテキスト ボックスが無効になるはずです。

リピーターの各行でこれを機能させることができるように、誰か親切に教えてもらえますか?

ありがとう!

4

2 に答える 2

0

これを試して

$('.dropdown').change(function()
{
   //include condition to determine "if dropdown is selected to be 1"

   var $row = $(this).parents('tr:first'); //find the row in which this dropdown is
   if($(this).val() == 1)
   {

     $row.find('.textbox:first').attr('disabled','disabled');​​​​​​ //assuming you put a class on your textbox
     //$row.find('.textbox:first').attr('disabled','true');​​​​​​
     //$row.find('.textbox:first').prop('disabled','true');​​​​​​
   }
   else
       $row.find('.textbox:first').attr('enabled','true'); //assuming you put a class on your textbox
});
于 2012-09-05T07:45:24.053 に答える
0

リピーターがテーブルとしてレンダリングされる場合。その後、試すことができます。

$("select").change(function(){
    var _this = $(this); 
    var parentRow = _this.closest('tr');
    if(_this.val() == "1"){
        parentRow.find("input[type=text]").prop("disabled", true);
    }else {
        parentRow.find("input[type=text]").prop("disabled", false);
    }
});
于 2012-09-05T07:50:24.063 に答える