<li><input onclick= "SelectAll (this); type=" checkbox "Name=" Controlall "id=" Controlall "/><label> Select All </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 ("Are you sure you want to assign all the items?" ", "");
$ ("#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 ("OK to cancel all project permissions?"). ", "");
$ ("#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 check box Select all to add to the database method