jsp实现全选

来源:互联网 发布:淘宝店铺链接在哪里 编辑:程序博客网 时间:2024/05/16 16:19



对jquery内容很薄弱,只能网上找找源码,这个是我经过实践可以用的一个案例。然后改写了一下,把其相关信息传送到后台,然后再在后台进行相关操作。

<%@taglib uri="/struts-tags" prefix="s"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
  <head>
 
<script src="http://code.jquery.com/jquery-1.4.4.min.js" type="text/javascript"></script>   
 <script type="text/javascript">
        $(function() {
           $("#checkAll").click(function() {
                $('input[name="subBox"]').attr("checked",this.checked); 
            });
            var $subBox = $("input[name='subBox']");
            $subBox.click(function(){
                $("#checkAll").attr("checked",$subBox.length == $("input[name='subBox']:checked").length ? true : false);
            });
              $("#allinput").click(function(){
                  var str="";
                  
                  $("input[name='subBox']").each(function(){ 
                  if($(this).attr("checked")){
                    str += $(this).val()+",";}
              });
              alert(str);
               $.ajax({
                    type : "post",
                    url : 'allout.action',
                    data : {//设置数据源
                        datasss : str
                    },
                    dataType : "json",//设置需要返回的数据类型
                    success : function(d) {
                        
                    },
                    error : function(d) {
                        
                    }
                });
            });
        });
    </script>
  </head>
  
  <body>
  <input type="checkbox" id="checkAll" />全选
  <input type="button" name="allinput" id="allinput" value="打印"/>
<form action="tianjiashangpinw.action" method="post" theme="simple">
<table border="1">
<s:iterator id="p" value="xianshilist">
<tr>
<td><input type="checkbox" name="subBox" value="<s:property value='#p.id'/>" /></td>
<td><s:property value="#p.id"/></td>
<td><s:property value="#p.sendname"/></td>
<td><s:property value="#p.sendphone"/></td>
<td><s:property value="#p.sendaddress"/></td>
<td><s:property value="#p.getname"/></td>
<td><s:property value="#p.getphone"/></td>
<td><s:property value="#p.getaddress"/></td>
</tr>
</s:iterator>
</table>
</form>
  </body>
</html>

参考文章相关网址。

http://www.blogjava.net/RoyPayne/archive/2012/03/02/371115.html

http://www.oschina.net/code/snippet_119416_5689



我自己写的一个代码:http://download.csdn.net/detail/u013936945/9599707(里面包含数据库,一般来讲是直接可以跑的了)


0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 佛山市住房公积金管理中心 住房公积金查询个人账户 19住房商业贷款利率 四川省住房和城乡建设厅首页 住房商业贷款利率 佛山住房公积金管理中心 四川住房城乡建设厅 西安住房公积金管理中心 住房公积金贷款额度 沧州住房公积金查询 个人住房公积金查询入口 银行住房贷款利率计算器 合肥市住房公积金管理中心 山东省住房和城乡建设厅 2019商业住房贷款利率 住房和城乡建设部 长春住房公积金 四川省住房城乡建设厅首页 新乡市住房公积金管理中心 住房贷款利率计算器 邵阳市住房公积金管理中心 邵阳住房公积金 商业住房贷款利率 陕西省住房公积金管理中心 合肥住房公积金管理中心 长春市住房公积金 山东省住房城乡建设厅 2019各银行住房商贷利率一览表 住房公积金查询入口 陕西省住房和城乡建设厅网 沧州住房公积金个人查询入口 包头市住房公积金管理中心 佛山住房公积金中心 个人住房商业性贷款 住房公积金装修贷款能贷多少 邵阳住房公积金管理中心 工资4000住房公积金一般交多少 西安住房保障管理局网站 佛山住房公积金 住房城乡建设部 河南省住房和城乡建设厅网