checkBox的全选与全不选

//初始加载
$(function () {
 
LoadCart();
});
var RMB = 0;
var Index = 0;
var shu = 0;
var ResultStr = "";
var userID = 0;
function LoadCart() {
var parameter = { action: "loadcart" };
var ResultStr = "";
$.ajax({
type: "Post",
async: true,
cache: false,
url: "/ashx/ZWY.ashx",
data: parameter,
dataType: "json",
crossDomain: true,
success: function (data) {
if (data.Success == 1) {
 
if (data.ObjDataList.Objdata.length > 0) {
var price = "";
 
 
price += " <tr class=\"quanxun\" style=\"border: 1px solid #eaeaea;\">";
price += " <th width=\"13%\">";
price += " <input class=\"selectAll\" οnclick=\"quanxuan()\" checked=\"\" type=\"checkbox\" id=\"chch\" name=\"checkbox22\" value=\"\" />全选</th>";
price += " <th>职业人名称</th>";
price += " <th>职业类型</th>";
price += " <th>订单金额(元)</th>";
price += " <th>订金金额(元)</th>";
price += " <th>操作</th>";
price += " </tr>";
price += " <tr class=\"jg\">";
price += " <td colspan=\"6\">&nbsp;</td>";
price += " </tr>";
 
price += " <tr id=\"prr\">";
 
 
price += " </tr>";
$.each(data.ObjDataList.Objdata, function (i, item) {
userID = item.CartID;
 
RMB += item.SvrRMB;
shu = i;
Index += i;
 
 
 
price += " <tr class=\"m-judge\" style=\"border-top: 1px solid #eaeaea; border-bottom: 1px solid #eaeaea;\">";
price += "";
price += " <td class=\"checkBtn\">";
price += " <input name=\"checkbox\" class=\"checkbox0\" checked=\"\" οnclick='javascript:sum("+i+"," + item.SvrRMB + ");' id=\"checkbox" + i + "\" ushop=\"4a2a19d3-a2f4-40d3-96e4-454a98202f28\" useri=\"97bf6d07-deea-4af8-95a3-983472b63306\" type=\"checkbox\" /><img style=\"cursor: pointer;\" width=\"62\" height=\"62\" οnclick=\"jumpNewPage\('4a2a19d3-a2f4-40d3-96e4-454a98202f28','XIAOYU','')\" src=\"" + item.AvatarImage + "\" />";
price += " </td>";
price += " <td>";
price += "";
price += "";
price += " <a href=\"#\" target=\"_blank\">"+item.RealName+"</a>";
price += "";
price += "";
price += "";
 
price += " </td>";
price += " <td>";
if (item.UserIdentity == 3) {
price += "主持人";
}
else if (item.UserIdentity == 4) {
price += "摄影师";
}
else if (item.UserIdentity == 5) {
price += "摄像师";
}
else if (item.UserIdentity == 6) {
price += "化妆师";
}
 
price += " </td>";
price += " <td><em class=\"totalB\">" + item.SvrRMB + "</em></td>";
price += " <td><em class=\"depositB\">"+item.SvrRMB/2+"</em></td>";
price += " <td><em class=\"depositB1\"><a href=\"#\" >删除</a></em></td>";
price += " </tr>";
ResultStr += " <span class=\"rf\">已选中的婚礼人<em class=\"num\" id=\"totalPeople\">" + (Index + 1) + "</em>个&nbsp;&nbsp;&nbsp;&nbsp;";
ResultStr += "订单总价:<em>¥</em><em class=\"num\" id=\"totalPrice\">" + RMB + "</em>&nbsp;&nbsp;&nbsp;&nbsp;";
ResultStr += "您需要支付订金:<em>¥</em><em id=\"depositPrice\" class=\"num\">" + RMB / 2 + "</em>&nbsp;&nbsp;&nbsp;&nbsp;";
ResultStr += " <a href=\"/upages/Shopping/cartOrder.aspx?UserID=" + item.CartID + "&MoneyID="+RMB+"\" class=\"qjs01 payButton\" id=\"payButton\">去结算</a>";
ResultStr += " </span>";
 
$("#allMtp").empty();
$("#allMtp").html(ResultStr);
 
});
$("#prr").empty();
$("#prr").html(price);
 
 
 
 
}
else {
 
}
} else {
layer.msg(data.SuccessStr, { icon: 2 });
}
}
});
}
var jk = 0;
function sum(i, www) {
if ($('input[id="checkbox' + i + '"]').prop("checked")) {
Index = Index + 1;
RMB = RMB + www;
ResultStr = "";
 
ResultStr += " <span class=\"rf\">已选中的婚礼人<em class=\"num\" id=\"totalPeople\">" + (Index + 1) + "</em>个&nbsp;&nbsp;&nbsp;&nbsp;";
ResultStr += "订单总价:<em>¥</em><em class=\"num\" id=\"totalPrice\">" + RMB + "</em>&nbsp;&nbsp;&nbsp;&nbsp;";
ResultStr += "您需要支付订金:<em>¥</em><em id=\"depositPrice\" class=\"num\">" + RMB / 2 + "</em>&nbsp;&nbsp;&nbsp;&nbsp;";
ResultStr += " <a href=\"/upages/Shopping/cartOrder.aspx?UserID=" + userID + "&MoneyID=" + RMB + "\" class=\"qjs01 payButton\" id=\"payButton\">去结算</a>";
ResultStr += " </span>";
}
else {
//alert("没选中");
chch.checked = false;
Index = Index - 1;
RMB = RMB - www;
ResultStr = "";
 
ResultStr += " <span class=\"rf\">已选中的婚礼人<em class=\"num\" id=\"totalPeople\">" + (Index + 1) + "</em>个&nbsp;&nbsp;&nbsp;&nbsp;";
ResultStr += "订单总价:<em>¥</em><em class=\"num\" id=\"totalPrice\">" + RMB + "</em>&nbsp;&nbsp;&nbsp;&nbsp;";
ResultStr += "您需要支付订金:<em>¥</em><em id=\"depositPrice\" class=\"num\">" + RMB / 2 + "</em>&nbsp;&nbsp;&nbsp;&nbsp;";
ResultStr += " <a href=\"/upages/Shopping/cartOrder.aspx?UserID=" + userID + "&MoneyID=" + RMB + "\" class=\"qjs01 payButton\" id=\"payButton\">去结算</a>";
ResultStr += " </span>";
}
 
 
$("#allMtp").empty();
$("#allMtp").html(ResultStr);
}
 
 
function quanxuan() {
if ($('#chch').prop("checked")) {
$('input[name="checkbox"]').each(function (index,item) {
if ($(item).prop("checked")) {
 
} else {
$(item).trigger('click');
}
});
 
 
}
else {
$(".checkbox0:checked").trigger('click');
}
 
 
---------------------------------------------------------------------------------------------------------
var idarray = [];
//遍历选中路径
$('input[name="checkbox"]:checked').each(function () {
idarray.push($(this).val());
});
for (var i = 0; i < idarray.length; i++) {
alert(idarray[i]);
}
 
//全选与全不选
if ($('#chch').prop("checked")) {
 
$('input[name="checkbox"]').attr("checked", true);
//$('input[name="checkbox"]').trigger('click');
} else {
$('input[name="checkbox"]').attr("checked", false);
}
 
 
 
 

转载于:https://www.cnblogs.com/zwyAndDong/p/7372144.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值