c#
  • jquery
  • asp.net
  • json
  • asp.net-mvc
  • 2016-05-09 24 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

    相关问题