c#
  • jquery
  • asp.net
  • json
  • asp.net-mvc
  • 2016-05-09 149 views -2 likes 
    -2

    我有一個動態創建的html表。在這個表中有複選框。在這裏我使用checkbox_status,如果checkbox_status == 1,然後選中一個複選框。複選框只讀/根據狀態禁用

    什麼,我需要做的是

    如果checkbox_status == 1,那麼我需要閱讀只是該複選框(或禁用複選框)

    我的編碼。(在這裏我把編碼的一部分)

    var _html = "<table class='table table-bordered table-responsive refundfontcolor' id='newstable' style='background-color:#002060;color:white;'><thead><th>#</th><th>News Id:</th><th>Name</th><th>Description</th></thead><tbody>"; 
    $.each(data, function (index, val) { 
        debugger; 
        checkbox_status = (val.IsReject == 1) ? 'checked' : ''; 
        _html += "<tr id=" + val.NewsId + " style='background-color:white;color:black'><td><input type='checkbox' " + checkbox_status + " id=" + val.NewsId + " ></td><td><p>" + val.Name + "&nbsp;&nbsp;</p></td><td><p>" + val.Description + "&nbsp;&nbsp;</p></td></tr>"; 
        $('#newstable').html(_html + "</tbody></table>"); 
    }); 
    

    回答

    1

    這將工作?

    <input type='checkbox' " + checkbox_status + " id=" + val.NewsId + " "+(checkbox_status=='checked' ? 'disabled':'')+"> 
    
    +0

    工作... thx。 – TechGuy

    相關問題