【多选 】批量处理 input

本文介绍了一个用于批量发货的JavaScript脚本,包括输入筛选、数据验证、发货状态更新等关键步骤。脚本通过确认对话框确保操作的正确性,并使用AJAX实现后台数据交互。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


//批量处理
<script type="text/javascript">
         function recordSend(){
            var ids='';
            $("input[name^=ids").each(function() {              
                if ($(this).attr("checked")) {  
                    ids += ","+$(this).val();  
                }              
            });
            if($.trim(ids)!='' && confirm('确认要进行批量发货吗?')){
                $.getJSON("{:U('order/updateSendIdsP')}&ids="+ids+"&callback=?",function(data){                    
                    if(data.code==1){
                        location.reload();
                    }else{
                        alert(data.message);
                    }
                });
            }
        }
</script>

/**
     * 批量发货( 只能发货,不可取消发货)
     */
    public function updateSendIdsP(){
		$ids= trim(trim(I("ids")),',');
		$idsArr=explode(',',$ids);
		foreach($idsArr as $k=>$id){
			if((int)$id<1){
				$return = array('message' => '参数有误','code' =>2);
				$this->ajaxReturn($return, 'JSONP');
				exit;
			}
		}
		$sqlWhere="id in (".$ids.") and virtual=1";
		$count = $this->model->where($sqlWhere)->count();
		if(count($idsArr)!=$count){
			$return = array('message' => '参数有误,有不是实物的id','code' =>3);
			$this->ajaxReturn($return, 'JSONP');
		}
		$data['send']=1;
               $rst = $this->model->where($sqlWhere)->save($data);
		if( $rst>=0){
			$return = array('message' => '更新成功','code' =>1);
		}else{
			$return = array('message' => '更新失败','code' =>4);
		}
		$this->ajaxReturn($return, 'JSONP');
	}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值