layui根据id获取复选框选中列表

1.复选框

 <td><input type="checkbox" name="checkbox_name_sel_ids" value="{{item.uid}}"></td>

2.获取复选框选中状态

fn.distributeAll = function() {
			var checkbox=$("input[name='checkbox_name_sel_ids']"); //复选框对象
			var selId = new Array();
		    for(var i = 0; i < checkbox.length; i++){
		     	if(checkbox[i].checked){
		     		selId.push(checkbox[i].value);
		     	}	 
		    } 
            layer.confirm('确认分配优惠券吗?', {icon: 3, title:'提示'}, function(index){
                index && http.POST('user/roleCouponUser/saveALL', {
                	selId : selId.join(),
                    pre_id:pre_id
                }).then(function(res) {
                    layer.msg(res.message);
                });
              layer.close(index);
            });
        }

3.以字符串的形式(以逗号分隔)在后台获取

    /**
     * 保存优惠券信息
     */
    @ValidateToken(isValidate = false)
    public void saveALL() {
    	String selId = getPara("selId");
    	String[] ids=selId.split(",");
    	String pre_id = getPara("pre_id");
    	Record re = RoleCouponService.findInfo(pre_id);
    	int days = re.getInt("days");
    	
    	for(String s:ids){
    		JSONObject where = getJsonWhere();
            where.put("uid", s);
            where.put("coupon_id", pre_id);
            where.put("describe", re.getStr("describe"));
            where.put("coupon_money", re.getStr("coupon_money"));
            where.put("name", re.getStr("name"));
            Date date = new Date();
            
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            String currdate = format.format(date);
            System.out.println("当前日期是:" + currdate);
            where.put("start_date", currdate);
            Date addDate = addDate(days);
            
            where.put("end_date", format.format(addDate));
            System.out.println(where);
            System.out.println("到期时间是:"+format.format(addDate));
           
            renderJson(srv.modify(where));
        	}
    }

使用微信小程序云开发写的个人简历小程序和好玩的关联微信运动遛狗的小程序,内置天气查询功能。欢迎大家扫码体验,项目详情也可到我的置顶博客查看。项目都已在码云上开源,欢迎大家star。wx_superpet这个小程序项目特别适合对微信小程序云开发技术感兴趣的同学参考。
个人简历源码:个人简历码云地址
wx_superpet源码:wx_superpet码云地址
wx_superpet
个人简历小程序码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值