![](https://i-blog.csdnimg.cn/blog_migrate/dea2f110dc6836b7c072549f0fcb890f.png)
1. 表头全选-----------------------------
2. <thead>
3. <th width="15%">
4. 是否发红包 <input type='checkbox' οnclick="selectAll()"/>
5. </th>
6. <th width="15%">
7. 金额 <input type="text" style="width: 25%;" name="ysz" id= "ysz" value ="0" οnchange="jjfz()"/>
8. </th>
9. <th width="15%">
10. 是否鼓励奖 <input type='checkbox' οnclick="selectAll2()" />
11. </th>
12.
13. </thead>
14.
15. 行内单选-----------------------------
16. <td>
17. <input type='checkbox' name='header' value ="<%=b.getId()%>" />
18. </td>
19.
20. <td>
21. <input type="text" style="width: 25%;" name='jine' id="jine<%=i %>" value ="0" />元
22. </td>
23.
24. <td>
25.
26. <input type='checkbox' name='header2' id="isgl<%=i %>" value ="1"/>
27. </td>
28. jQuery全选---------------------------
29. function selectAll() {
30. if ($("#header").is(":checked")) {
31. $('input[name=header]').prop("checked", false);
32.
33. } else{
34. $('input[name=header]').prop("checked", true);
35.
36. }
37. }
38.
39. -----数据拼接后传值到Action-------------------
40. function gotoAdd()
41. {
42. var chk=[];
43. var chk2=[];
44. var je=[];
45. $('input[name=header]').each(function(){
46.
47. var nu=this.checked ? $(this).val():0;
48. chk.push(nu);
49. });
50.
51. $('input[name=header2]').each(function(){
52. var num=this.checked ? 1:0;
53. chk2.push(num);
54. });
55.
56. $('input[name=jine]').each(function(){
57. je.push($(this).val());
58. });
59.
60. if (chk.length==0){
61. alert("是否发红包选项不能为空!");
62. return;
63. }
64.
65. document.selectForm.action="<%=basePath%>xxxxAction.do?method=xxxxxx&chk="+chk+"&je="+je
66. +"&isguli="+chk2;
67. document.selectForm.submit();
68. }
69.
70. -----后台取值--------------
71. String chk = request.getParameter("chk");
72. String je = request.getParameter("je");
73. String guli = request.getParameter("isguli");
74. String[] arr= chk.split(",");
75. String[] jine=je.split(",");
76. String[] isgl=guli.split(",");