zoukankan      html  css  js  c++  java
  • input框checkBox全选单选js操作,后台取值



    bootstrap 样式代码

    <div class="md-checkbox has-success">
    	<input type="checkbox" id="rlt-chk-all-checkboxBox-work" class="md-check"     name="ult-chk-all-work">
    		<label for="rlt-chk-all-checkboxBox-work">
    		<span class="inc"></span>
    		<span class="check"></span>
    		<span class="box"></span>
    		</label>
    		</div>
    
    //table  tbody中
    
    <c:forEach items="${projectList }" var="item" varStatus="li">
    
        <div class="md-checkbox has-success">
       <input type="checkbox" id="rlt-chk-checkbox${li.count }" class='ult-chk' name='rlt-chk-work' value=" ${item.ID }">
    	<label for="rlt-chk-checkbox${li.count }">
    	<span class="inc"></span>
    	<span class="check"></span>
    	<span class="box"></span>
    	</label>
    	</div>
    
    </c:forEach>

    //全选按钮功能

    	$('[name=ult-chk-all-work]').on('change', function(){
    		$('[name=rlt-chk-work]').prop('checked', $('[name=ult-chk-all-work]').prop('checked'));
    	});

    //按钮执行js逻辑

    $("#button").click(function(){
    var workIds = [];  
        $('[name=rlt-chk-role]:checked').each(function(index, item){  
    workIds.push(item.getAttribute('value'));
    }); 
     $.post("url",{data:workIds.toString()},function(data){
        逻辑处理
    })
    <!--执行的业务逻辑   把value   toString在传入后台   workIds.toString(),然后后台直接split 分割取值就行
        eg: String workIdsString = request.getParameter("workIds");
          String[] roleIds = String.split(",");
    })
    



  • 相关阅读:
    弹性布局、动画、过渡
    HTML
    数据库对象
    函数
    oracle与PL/SQL安装
    网络编程
    多线程
    联调接口
    vue 全局变量
    vue ajax请求
  • 原文地址:https://www.cnblogs.com/liclBlog/p/15349585.html
Copyright © 2011-2022 走看看