2012-09-04 56 views
1

我生成以下從asp.net經常性的標記 -jQuery的實現基於用戶選擇/禁用asp.net控制

 <tr id="trRow0" class="trClass"> 
      <td id="cell0" class="tdClass"> 
       <input id="MainContent_rptColleges_rbCollege_0" type="radio" name="ctl00$MainContent$rptColleges$ctl01$rbCollege" value="mit" /> 
       mit 
      </td> 
      <td> 
       <ul> 
        <li> 
         <input id="MainContent_rptColleges_rptCourses_0_rbCourse_0" type="radio" name="ctl00$MainContent$rptColleges$ctl01$rptCourses$ctl01$rbCourse" value="computer science" /> 
         &nbsp; computer science 
        </li> 
        <li> 
         <input id="MainContent_rptColleges_rptCourses_0_rbCourse_1" type="radio" name="ctl00$MainContent$rptColleges$ctl01$rptCourses$ctl02$rbCourse" value="mechanical engg." /> 
         &nbsp; mechanical engg. 
        </li> 
       </ul> 
      </td> 
     </tr> 
     <tr id="trRow1" class="trClass"> 
      <td id="cell1" class="tdClass"> 
     **... 
     ...** 

一旦任何行學院單選按鈕,用戶點擊,載有兒童的單選按鈕有被啓用。選擇其他行後,應重置/禁用先前選擇的子單選按鈕。

我已經使用jQuery取得成功的一半,用下面的代碼獲取所選行TR ID,

$(document).ready(function myfunction() {    
     $('[id*=rbCollege]').click(function (e) { 
      var selectedCollegeRow = jQuery(this).parent().parent().attr("id"); 
      $(selectedCollegeRow).find('input[name$=rbCourse]'). //code to enable disable radio 
     }); 
    }); 

我錯過其他什麼信息?

回答

0

設置disabled屬性:

$(document).ready(function myfunction() {    
    $('[id*=rbCollege]').click(function (e) { 
     var selectedCollegeRow = jQuery(this).parent().parent().attr("id"); 
     $(selectedCollegeRow).find('input[name$=rbCourse]').attr('disabled', 'true'); 
    }); 
}); 
+0

感謝您的答覆,但在這裏,我的目標是使當前行選課,並禁止他人,ATTR(「禁用」,「真」)不會做需要的事情。 – Abhijeet