码迷,mamicode.com
首页 > 数据库 > 详细

MVC 复选框全选 添加到数据库方法

时间:2014-11-17 17:09:47      阅读:281      评论:0      收藏:0      [点我收藏+]

标签:io   ar   os   sp   for   数据   on   cti   bs   

<li><input onclick="selectAll(this);" type="checkbox" name="controlAll"  id="controlAll" /><label>全选</label></li>

  <li><input name="itemname" type="checkbox" value="@item.ProjectId" /><label>@item.Name</label></li>

function selectAll(obj) {               

var status = $(obj).prop("checked");            

//alert(status);            

var checklist = document.getElementsByName("itemname");                     

if (document.getElementById("controlAll").checked) {                

myconfirm("确定要分配全部项目吗?", "");                

$("#confirmBtnDetermine").click(function () {                    

var projectId = "";                    

for (var i = 0; i < checklist.length; i++) {                        

if (checklist[i].checked == 0) {                            

checklist[i].checked = 1;                            

projectId += ","+checklist[i].value;                    

     }                     }                    

// alert(projectId);                    

$.ajax({                        

type: "POST",                        

url: ‘@Url.Action("AllAddEditSubmit", "Permission")‘,                        

dataType: "json",                        

data: { projectId: projectId, employeeId: ‘@ViewBag.EmployeeId‘,status: status },                       

  success: function (data) {                           

  if (data.Result) {                               

  myalert(data.Message, "");                            

} else {                                

myalert(data.Message, "");                           

  }                       

  }                   

  });                

})

            }            

else {               

  myconfirm("确定要取消所有项目权限吗?", "");               

  $("#confirmBtnDetermine").click(function () {                   

  var projectId = "";                   

  for (var j = 0; j < checklist.length; j++) {                       

  checklist[j].checked = 0;                       

  projectId += "," + checklist[j].value;

                    }                    

$.ajax({                        

type: "POST",                      

   url: ‘@Url.Action("AllAddEditSubmit", "Permission")‘,                    

     dataType: "json",                     

    data: { projectId: projectId, employeeId: ‘@ViewBag.EmployeeId‘,status: status },                     

    success: function (data) {                           

  if (data.Result) {                               

  myalert(data.Message, "");                        

     } else {                               

  myalert(data.Message, "");                      

       }                         }                     });

                });             }         }

MVC 复选框全选 添加到数据库方法

标签:io   ar   os   sp   for   数据   on   cti   bs   

原文地址:http://www.cnblogs.com/HeroesCenter/p/4103733.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!