MVC check box Select all to add to the database method

Source: Internet
Author: User

<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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.